I'm working with the emulated EEPROM of MC9S12XET256 device. I followed the instructions in Application Note AN3743 and was able to emulate the EEPROM and read and write Bytes in it, using pointers, like it does in the application note.
Then I've read in Application Note AN3490 that "EEE is designed for optimal use with align word (16-bit) data", so I'm trying to do operations of read and write in EEPROM using pointers to Word instead of pointers to Byte. But seems that only the Low Byte can be read or written, the High Byte goes to zero or some garbage.
Below are some example of code I'm using. When I use this code with "unsigned char" instead of "unsigned int" it works perfectly.
//Declaration of pointer and variables
unsigned int *pointer;
unsigned int value_read, value_written;
//To read the value in position 0x0F00 of EEPROM, for example
pointer = (unsigned int *) 0x0F00;
value_read = *pointer;
//To write in position 0x0F02 of EEPROM, for example
pointer = (unsigned int *) 0x0F02;
*pointer = value_written;
So, what am I doing wrong? Can I access the EEPROM by word or only by bytes?
Is the pointer association correct?
Thanks in advance,