This thread has been locked.

If you have a related question, please click the "Ask a related question" button in the top right corner. The newly created question will be automatically linked to this question.

order of bit structure

Other Parts Discussed in Thread: HALCOGEN

Hi,

I am using the TMS570 with CCS6 and Halcogen 4.1.

 

I have the following bit structure that I am porting from a different processor, and it looks like the order of the bit structure is reversed.  For example, I would expect frameid_out to be bit 0, and pip closed to be bit 13.  But when I toggle pip closed, the 13th bit from the right toggles, not the 13th bit from the left.  I believe the old processor is little endian, and the TMS570 is big endian.

 

Is there a way to force the bit order?

 

typedef union FrameIn_Obj
{
   uint32_t   lword;
   struct
    {
      unsigned int  frameid_out     : 1;
      unsigned int  encoder2_id     : 1;
      unsigned int  rlypwr_ok       : 1;
      unsigned int  estop_ok        : 1;
      unsigned int  upperTravLmt    : 1;
      unsigned int  lowerTravLmt    : 1;
      unsigned int  drv_enabled     : 1;
      unsigned int  pwramp_ok       : 1;
      unsigned int  motortmp_ok     : 1;
      unsigned int  topgrip_closed  : 1;
      unsigned int  botgrip_closed  : 1;
      unsigned int  closegrip_req   : 1;
      unsigned int  intrlock_ok     : 1;
      unsigned int  pip_closed      : 1;
      unsigned int  handset_up      : 1;
      unsigned int  handset_dn      : 1;
      unsigned int  clutch_switch   : 1;
      unsigned int  FIBFrameFault   : 1;
      unsigned int  shieldDoorOpen  : 1;
      unsigned int  shieldDoorClosed: 1;
      unsigned int  safeMode        : 1;
      unsigned int  setupMode       : 1;
      unsigned int  FIBWdog         : 1;
      unsigned int  high_clutch     : 1;
    } bits;
} FrameIn_Obj;

 

  • Hi David,

    This would be a great post for the compiler forum.   Certainly at one time what you're talking about was an area that was not covered by the C standard and left up to the compiler (packing of bitfields).   But maybe the new C standards or some standard like ARM's EABI would close this loophole for you.   I don't know - but the folks that monitor the compiler forum are experts and probably would know.