AnsweredAssumed Answered

stm32l eeprom erase problem

Question asked by pinco.dave on May 17, 2012
Latest reply on May 30, 2012 by pinco.dave
I tried to make an erase of a valid address of data eeprom available on my stm32l151.
When I try to write 0x00000000 for instance to address 0x0808001B Keil uVision stops the debug mode give me a message of error.The error is something like "device disconnected while debug is executing.Please check the JTAG connection." while the device stops itself and don't keeps on perform the execution of the program.I must reset it pulling down the reset pin in order to start the debug again.
The code I used is the following:

void write_eeprom(uint32_t address,uint32_t data){
          FLASHStatus = DATA_EEPROM_ProgramWord (address, data);
               printf("eeprom write ok!\n");

uint32_t read_eeprom(uint32_t address){
     uint32_t tmp=0;
          tmp=*(__IO uint32_t*)address;
     return tmp;

Going step by step in debug mode, I discovered that when the Data=0x00000000 is the line 13 of the following code to make the disaster:

1 FLASH_Status DATA_EEPROM_ProgramWord(uint32_t Address, uint32_t Data)
2 {
3   FLASH_Status status = FLASH_COMPLETE;
5   /* Check the parameters */
6   assert_param(IS_FLASH_DATA_ADDRESS(Address));
8   /* Wait for last operation to be completed */
9   status = FLASH_WaitForLastOperation(FLASH_ER_PRG_TIMEOUT);
11   if(status == FLASH_COMPLETE)
12   {
13     *(__IO uint32_t *)Address = Data;
15     /* Wait for last operation to be completed */
16     status = FLASH_WaitForLastOperation(FLASH_ER_PRG_TIMEOUT);        
17   }
18   /* Return the Write Status */
19   return status;
20 }

The only idea that I have is that the code is writing to a wrong address that is not pat of the eeprom.Anyway it happens only when I try to write 0 while it's ok when there is any other value.
Please do you have any idea?