STEVE TRACHT

Packing 12 bit data on MC9S12XET256

Discussion created by STEVE TRACHT on Jul 2, 2010
Latest reply on Jul 14, 2010 by kef

We are sampling some A2D data and storing it to external RAM. The data comes in threes. Initially, we created a structure like this:

 

typedef struct {

  uint16_t   xData;

  uint16_t   yData;

  uint16_t   zData;

} dataStructureType;

 

(We use the MISRA C recommended data types.)

 

We'd like to pack the data, because we're storing 500 MBytes of data in external RAM and not using 25% of the RAM. If we group the data into four sets of three 12 bit unsigned integers, we can get 144 bits which is divisible by 16. We thought about the following structures:

 

typedef struct {

  uint16_t   xData:12;

  uint16_t   yData:12;

  uint16_t   zData:12;

} dataStructureType;

 

typdef struct {

  dataStructureType   dataSet0;

  dataStructureType   dataSet1;

  dataStructureType   dataSet2;

  dataStructureType   dataSet3;

} dataSetStructureType;

 

I'm not quite sure what we'll get with this though. Will it even pack the data? Is there a better way to structure it or should we just write routines to pack the data? I'd like to make the data explicit and that's why I'm avoiding routines to pack the data.

 

Steve

Outcomes