EmbeddedRelated.com
Forums

Can't write to flash memory

Started by ffredrik July 12, 2007
hi,

u should read this errata which i read in AT91SAM7S64 (PRelim_SAM7S64_big.pdf)

read the errata for Master Clock page 541

u have to set the

AT91C_BASE_MC->MC_FMR

register with apporpiate wait states while startup or else while flashing it generates exceptions

i am running the controller at 48 Mhz
and have the set the wait states as

AT91C_BASE_MC->MC_FMR = ((AT91C_MC_FMCN)&(48 <<16)) | AT91C_MC_FWS_1FWS ;

check if it works

Regards,
Shraddha

ffredrik wrote:
Hi Mark,

I wait for the write to finish, the way you do it.
The processor traps to "undefined instruction" when
I try to write MC_FCR

Fredrik

Mark Butcher wrote: Hi

I can't explain the problem that you have from the details that I have
seen. You have written that the code is running out of RAM and
interrupts are blocked, which would be correct.

Are you waiting for the FLASH to signal that it has completed after
the write? Could you be leaving the region before it is ready
(although I don't think that this would be address dependent).

Eg.
MC_FCR = (FLASH_KEY | FCMD_WP | (ulPage<<8));
while (!(MC_FSR & FLASH_READY)) {}

Regards

Mark

www.uTasker.com

Yahoo! Groups Links

---------------------------------
Unlimited freedom, unlimited storage. Get it now
Hi Fredrik,

I found the problem, I am using yagarto toolchain with exclipse.
My problem was that, Master clock set with 48Mhz and running clock with 18.432Mhz, by this way the configuration to write flash was wrong, when both Master clock and running clock was set with 48Mhz, the write to flash works ok.

I did not understand this, because if I tell cpu that runnning clock is 18.432Mhz and cristall is 18.432Mhz too, why writting to flash crash cpu.

regards

Paulo

----- Original Message -----
From: ffredrik
To: A...
Sent: Thursday, September 06, 2007 3:13 AM
Subject: Re: [AT91SAM] Re: Can't write to flash memory
Hi Paulo,

I still have the problem. It seems to appear occasionally, after certain
rebuilds. Can't figure out what causes it. What compiler do you use?

Fredrik
Paulo Silva wrote:

HI

I am having the same problem.

When I run the program via debug no problem codes works, but when I run it normaliy, cpu crashs when execute MC_FCR = MC_KEY | CMD;

Any sugestions about this, I am using Olimex SAM7-EX256 board.

Regards

Paulo

----- Original Message -----
From: shraddha chaudhari
To: A...
Sent: Thursday, July 19, 2007 11:57 AM
Subject: Re: [AT91SAM] Re: Can't write to flash memory
hi,

u should read this errata which i read in AT91SAM7S64 (PRelim_SAM7S64_big.pdf)

read the errata for Master Clock page 541
u have to set the

AT91C_BASE_MC->MC_FMR

register with apporpiate wait states while startup or else while flashing it generates exceptions

i am running the controller at 48 Mhz
and have the set the wait states as

AT91C_BASE_MC->MC_FMR = ((AT91C_MC_FMCN)&(48 <<16)) | AT91C_MC_FWS_1FWS ;

check if it works

Regards,
Shraddha

ffredrik wrote:
Hi Mark,

I wait for the write to finish, the way you do it.
The processor traps to "undefined instruction" when
I try to write MC_FCR

Fredrik

Mark Butcher wrote:
Hi

I can't explain the problem that you have from the details that I have
seen. You have written that the code is running out of RAM and
interrupts are blocked, which would be correct.

Are you waiting for the FLASH to signal that it has completed after
the write? Could you be leaving the region before it is ready
(although I don't think that this would be address dependent).

Eg.
MC_FCR = (FLASH_KEY | FCMD_WP | (ulPage<<8));
while (!(MC_FSR & FLASH_READY)) {}

Regards

Mark

www.uTasker.com

Yahoo! Groups Links

--
Unlimited freedom, unlimited storage. Get it now