Tip / Sign in to post questions, reply, level up, and achieve exciting badges. Know more

cross mob

Bit field structure difference between PSoC 1's HiTech Compiler and PSoC3's Keil Compiler

Bit field structure difference between PSoC 1's HiTech Compiler and PSoC3's Keil Compiler

Anonymous
Not applicable
Question: While migrating a bit field structure from PSoC Designer project to PSoC Creator project, structure does not work properly. Why it is so?

 

Answer:

The bit fields must be declared in the opposite order with the Keil compiler; LSB to MSB. Here is an example of the code difference required.

Hi-Tech Compiler:


struct
{
     // MSB
     unsigned Type : 4;
     unsigned TxSeqn : 1;
     unsigned Sync : 1;
     unsigned RxSeqAckn : 1;
     unsigned SingleByteDeviceId : 1;
     // LSB
} sHdr;


Keil Compiler:


struct
{

     // LSB
     unsigned char SingleByteDeviceId : 1;
     unsigned char RxSeqAckn : 1;
     unsigned char Sync : 1;
     unsigned char TxSeqn : 1;
     unsigned char Type : 4;
     // MSB
} sHdr;

0 Likes
368 Views
Contributors