'struct' size problem

cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 

'struct' size problem

Jump to solution
645 Views
sebasira
Senior Contributor I

Hello!

I'm used to work with structures, my whole application is based on them. Now I'm porting this 'old' app from HCS12 to K60... It's a HUGE change but it is not far for being over.

I've got a structure defined like this:

typedef struct{

      word mov;

      byte addressRx;

      byte addressTx;

      byte tipoReloj;

      byte empty[3];        // 3 empty bytes so the whole size is 4bytes-aligned

}tPARAM;

The problem is that every parameter inside this structure has a size of 4bytes instead of 2bytes for 'word' and 1byte for 'byte'. In HCS12 wich is a 16bit MCU I don't have this problem but I do in K60 wich is 32bits.


What can I do so the size of each parameter would be as expected?


Thanks in advance!!!

Best Regards,


SebaS

Labels (1)
0 Kudos
1 Solution
498 Views
sebasira
Senior Contributor I

My bad!

Not every parameter has 4byte size, but only the word one. The problem was that I declared word as unsigned int and I found out that others declare it as unsigned short.

Problem solved!!!!

View solution in original post

0 Kudos
1 Reply
499 Views
sebasira
Senior Contributor I

My bad!

Not every parameter has 4byte size, but only the word one. The problem was that I declared word as unsigned int and I found out that others declare it as unsigned short.

Problem solved!!!!

0 Kudos