This discussion has been locked.
You can no longer post new replies to this discussion. If you have a question you can start a new discussion

long bit fields

I am using the SPI to access a couple of 20 & 24 bit A/D converters which have some digital status bits preceding the reading. I already have some C code written (for another CPU) that defines the incoming data structure as a unsigned long. The Keil compiler, however, says I must use char or integer size bit fields. Is there an easy way around this without having to hand code the byte manipulation code manually?

Parents
  • Here is a simplified example.

    typedef struct {
     unsigned long det_in     :4,   /*compliance & short detection bits */
                   Brd_rev    :4,   /* board / pal revision  */
                   nu        :4,    /* not used as of 8/2000 */
                   AD_data    :20;  /* 0=-max, 0x80000=0v, fffff=+max */
                  } Bridge_brd_Rx_Type;  /* for each bridge card */
    
    I do use this variable type in a union of however many longs it takes.My end goal is to point a PEC register at this structure, let the SPI run, and then access the different bit fields as
     { long reading; char revision;
    reading = Brdg1.AD_data;
    revision = Brdg1.Brd_rev;
    ...
     }
    

Reply
  • Here is a simplified example.

    typedef struct {
     unsigned long det_in     :4,   /*compliance & short detection bits */
                   Brd_rev    :4,   /* board / pal revision  */
                   nu        :4,    /* not used as of 8/2000 */
                   AD_data    :20;  /* 0=-max, 0x80000=0v, fffff=+max */
                  } Bridge_brd_Rx_Type;  /* for each bridge card */
    
    I do use this variable type in a union of however many longs it takes.My end goal is to point a PEC register at this structure, let the SPI run, and then access the different bit fields as
     { long reading; char revision;
    reading = Brdg1.AD_data;
    revision = Brdg1.Brd_rev;
    ...
     }
    

Children
No data