MC9S12XET256 - Emulated EEPROM Word aligned access

キャンセル
次の結果を表示 
表示  限定  | 次の代わりに検索 
もしかして: 

MC9S12XET256 - Emulated EEPROM Word aligned access

ソリューションへジャンプ
1,852件の閲覧回数
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,516件の閲覧回数
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,516件の閲覧回数
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,517件の閲覧回数
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,516件の閲覧回数
LeandroLeite
Contributor II

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

0 件の賞賛
返信