This discussion has been locked.
You can no longer post new replies to this discussion. If you have a question you can start a new discussion

problems about the internal memory writing

Hi all,

I'm using the AT91SAM7S64 chip on the Evaluation Board AT91SAM7S-EK, and I'm trying to write the internal flash rom.

The code that I use is the follow:

unsigned int dato = 0xAABBCCDD;
unsigned int address = 0x00100000;
int page = 20;



AT91F_Flash_Init();
AT91F_Flash_Write_Page(address, dato);

void AT91F_Flash_Init (void)
{

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




}

int AT91F_Flash_Ready (void)
{
int status;
status = 0;

//* Aspetto la fine del comando
while ((status & AT91C_MC_FSR_FRDY) != AT91C_MC_FSR_FRDY )
{
status = AT91C_BASE_MC->MC_FSR;
}
return status;
}

int AT91F_Flash_Write_Page(unsigned int Flash_Address, unsigned int buff)
{

AT91PS_MC ptMC = AT91C_BASE_MC;




page = 510;

Flash = (unsigned int *) Flash_Address;

*Flash = buff;

//* Do il comando di scrittura
ptMC->MC_FCR = AT91C_MC_CORRECT_KEY | AT91C_MC_FCMD_START_PROG | (AT91C_MC_PAGEN & (page <<8)) ;

//* Aspetto la fine del comando




status = AT91F_Flash_Ready();

return (1);
}

My program haven't problem when I perform a debug step-by-step; instead my program doesn't work (go to "crash" !!!) when I try to run it.
Could you hel me? Thanks.

0