MC9S12XET256 - Emulated EEPROM Word aligned access

取消
显示结果 
显示  仅  | 搜索替代 
您的意思是: 
已解决

MC9S12XET256 - Emulated EEPROM Word aligned access

跳至解决方案
1,843 次查看
LeandroLeite
Contributor II

Hello,

 

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,

Leandro

标签 (1)
0 项奖励
回复
1 解答
1,507 次查看
LeandroLeite
Contributor II

Both the partitioning and the EEPROM emulation were correct.

 

But by a disregard I was pointing to odd addresses. When I tried to write and read only to even addresses the code worked fine!

 

Thanks for the help Kef!

Leandro

 

在原帖中查看解决方案

0 项奖励
回复
3 回复数
1,507 次查看
kef
Specialist I

Your code looks fine and should work.

Are you sure DFLASH is properly partitioned and eeprom emulation enabled? You need to issue Enable Eeprom Emulation command on each reset.

0 项奖励
回复
1,508 次查看
LeandroLeite
Contributor II

Both the partitioning and the EEPROM emulation were correct.

 

But by a disregard I was pointing to odd addresses. When I tried to write and read only to even addresses the code worked fine!

 

Thanks for the help Kef!

Leandro

 

0 项奖励
回复
1,507 次查看
LeandroLeite
Contributor II

By the way, I'm using CodeWarrior IDE Version 5.9.0.

0 项奖励
回复