I Can't modify data on eeprom memory
01-30-2007
06:30 PM
4,051件の閲覧回数

Bibi
Contributor I
- 新着としてマーク
- ブックマーク
- 購読
- ミュート
- RSS フィードを購読する
- ハイライト
- 印刷
- 不適切なコンテンツを報告
Hello !
I'm using a MC9S12DG128 microcontroler. I would like to modify data writen in eeprom memory.
The chip is used with a 16MHz oscillator.
I first initiate the memory mapping :
init_cpu(){
INITEE = 0x09;
INITRM = 0x11;
INITRG = 0x00;
}
Before writing data, I'm looking at the EDIVLD bit in the ESTAT register, if null I initiate the EEPROM registers :
void eeprom_init(){
ECLKDIV=0x4A;
ECNFG=0x00;//pas it eeprom
}
and then I modify the sector :
char modifiy_Sector(unsigned int * adr, unsigned int data){
ESTAT=0x30;//raz ACCERR et PVIOL
while(!(ESTAT & 0x80));
*adr=data;//fill address with data
*adr=data;//fill address with data
ECMD=0x60;//write command
ESTAT = 0x80;//activate command
if((ESTAT&0x30)!=0)
return(FALSE);
ESTAT = 0x80;//activate command
if((ESTAT&0x30)!=0)
return(FALSE);
while(!(ESTAT & 0x40));//wait for end of command
return(*adr==data);
}
The problem is that data are not written in the EEPROM memory ! Did I miss something or Is there any errors in my code ?
For more information, I'm using CW compiler, ISystem Debugger. My Controler is used in Normal single chip.
Thank you for your help !
Bibi
6 返答(返信)
01-31-2007
01:47 PM
1,740件の閲覧回数

Kantha
Contributor I
- 新着としてマーク
- ブックマーク
- 購読
- ミュート
- RSS フィードを購読する
- ハイライト
- 印刷
- 不適切なコンテンツを報告
Hi,
Call function eeprom_init() even if EDIVLD bit is not null
char modifiy_Sector(unsigned int * adr, unsigned int data)
{
ESTAT=0x30;//raz ACCERR et PVIOL
while(!(ESTAT & 0x80)); // remove this while condition
*adr=data;//fill address with data
*adr=data;//fill address with data
ECMD=0x60;//write command
ESTAT = 0x80;//activate command
if((ESTAT&0x30)!=0)
return(FALSE);
ESTAT = 0x80;//activate command
if((ESTAT&0x30)!=0)
return(FALSE);
while(!(ESTAT & 0x40));//wait for end of command
return(*adr==data);
}
remove the marked while condition. you can't issue more than one command unless it has been completed.
Regards,
Kantha
01-31-2007
07:02 PM
1,740件の閲覧回数

n_domblides
Contributor I
- 新着としてマーク
- ブックマーク
- 購読
- ミュート
- RSS フィードを購読する
- ハイライト
- 印刷
- 不適切なコンテンツを報告
Hi,
Thank you for your answer, but it seems not to resolve my problem. I analyse
every register needed by the EEPROM and I did'nt find any mistakes.
During my last tests, I've seen that the memory space I was considering as
the eeprom memory was acting as a RAM memory. I mean, when I am executing,
step by step, the command line *eepromAddress = data (as explaining in the
application note), the memory area is updating with the data even if the the
command was not run (with writing the ECMD register and ESTAT_CBIEF bit).
When I shut down the chip power, The memory area is no longer fill with data
I wrote but with random data.
So I thougth it was a mapping memory error.
I want the following mapping:
RAM : 0x1000 to 0x2FFF
EEPROM : 0x800 to 0xFFF
FLASH: 0x4000 et 0x8000
As explaining in the documentation, I configure the mapping registers as
followed:
INITRM = 0x11;
INITEE = 0x09;
INITRG = 0x00;
I saw in the application note you've sent to me, that if a RAM area is at
the same place as the EEPROM area, the sector is acting as a RAM memory. At
reset, the ram memory is placed from 0x0000 to 0x1FFF and is masking the
eeprom memory.What should I do to make the EEPROM visible.
Nicolas DOMBLIDES
Thank you for your answer, but it seems not to resolve my problem. I analyse
every register needed by the EEPROM and I did'nt find any mistakes.
During my last tests, I've seen that the memory space I was considering as
the eeprom memory was acting as a RAM memory. I mean, when I am executing,
step by step, the command line *eepromAddress = data (as explaining in the
application note), the memory area is updating with the data even if the the
command was not run (with writing the ECMD register and ESTAT_CBIEF bit).
When I shut down the chip power, The memory area is no longer fill with data
I wrote but with random data.
So I thougth it was a mapping memory error.
I want the following mapping:
RAM : 0x1000 to 0x2FFF
EEPROM : 0x800 to 0xFFF
FLASH: 0x4000 et 0x8000
As explaining in the documentation, I configure the mapping registers as
followed:
INITRM = 0x11;
INITEE = 0x09;
INITRG = 0x00;
I saw in the application note you've sent to me, that if a RAM area is at
the same place as the EEPROM area, the sector is acting as a RAM memory. At
reset, the ram memory is placed from 0x0000 to 0x1FFF and is masking the
eeprom memory.What should I do to make the EEPROM visible.
Nicolas DOMBLIDES
02-06-2007
04:56 AM
1,740件の閲覧回数

Kantha
Contributor I
- 新着としてマーク
- ブックマーク
- 購読
- ミュート
- RSS フィードを購読する
- ハイライト
- 印刷
- 不適切なコンテンツを報告
Hi,
Remap your RAM to 0x2000, ie INITRM = 0x20;
Regards,
Kantha
02-06-2007
01:55 PM
1,740件の閲覧回数

n_domblides
Contributor I
- 新着としてマーク
- ブックマーク
- 購読
- ミュート
- RSS フィードを購読する
- ハイライト
- 印刷
- 不適切なコンテンツを報告
Hi !
That's it !! I remapped my RAM memory and it's working !!
thank you everybody for your help.
Bibi
That's it !! I remapped my RAM memory and it's working !!
thank you everybody for your help.
Bibi
02-01-2007
01:36 PM
1,740件の閲覧回数

kef
Specialist I
- 新着としてマーク
- ブックマーク
- 購読
- ミュート
- RSS フィードを購読する
- ハイライト
- 印刷
- 不適切なコンテンツを報告
bibi,
you want to map your DG128 RAM to 1000-2fff. This is impossible since DG128 8K RAM block is "mappable to any 8K boundary". 8K boundary means $0, $2000, $4000, $6000 etc. You can't map DG128's 8K RAM to 1000-2fff. Only 0-1fff, 2000-3fff, etc
01-31-2007
01:40 PM
1,740件の閲覧回数

Kantha
Contributor I
- 新着としてマーク
- ブックマーク
- 購読
- ミュート
- RSS フィードを購読する
- ハイライト
- 印刷
- 不適切なコンテンツを報告
Hi,
You can't write into EEPROM unless it is empty, means data at that location should be 0xFFFF.
Regards,
Kantha
