cancel
Showing results for 
Search instead for 
Did you mean: 

STM32L053 EEPROM writing going to HardFault

Fran Buck
Associate II
Posted on March 17, 2017 at 23:00

Hi!

I am trying to write s string into the EEPROM of a STM32L053.

I create a strcpy like funtion, using STM32L0xx HAL Libraries:

for writing the EEPROM I use this sequence of HAL functions.

char ascii_string[200];

HAL_FLASHEx_DATAEEPROM_Unlock( );

HAL_FLASHEx_DATAEEPROM_Program( FLASH_TYPEPROGRAMDATA_BYTE, ( uint32_t ) dest_addr  , ascii_string[0] );

HAL_FLASHEx_DATAEEPROM_Program( FLASH_TYPEPROGRAMDATA_BYTE, ( uint32_t ) dest_addr + 1 , ascii_string[1] );

...

HAL_FLASHEx_DATAEEPROM_Program( FLASH_TYPEPROGRAMDATA_BYTE, ( uint32_t ) dest_addr + N-1, ascii_string[N-1]);

HAL_FLASHEx_DATAEEPROM_Lock( );

This works OK while debugging step by step, but when I run this freely, it goes to FaultHandler (and the write protect flag is ON).

I am using the 1.8 version of the HAL library.

I think is some timing issue. Could be something in regard the clock speed? (I am using 32MHz) .

Any help will be apreciated.

Thanks.

0 REPLIES 0