cancel
Showing results for 
Search instead for 
Did you mean: 

STM32L0 MCU EEPROM write

tropinka06
Associate
Posted on July 29, 2014 at 14:44

Hi.

I use Nucleo board with STM32L0x3 MCU. There are special sequence for EEPROM TYPEPROGRAM_BYTE process?

I can write 4 bytes data (TYPEPROGRAM_WORD) but can't write 1 byte data (TYPEPROGRAM_BYTE):

uint32_t

Address = 0;

uint32_t

data32 = 0x12345678;

uint8_t

ubData[10] = {0};

// write 4 bytes example - work

while

(Address < FLASH_USER_END_ADDR)

    {

       

if

(HAL_DATA_EEPROMEx_Program(TYPEPROGRAM_WORD, Address, data32) == HAL_OK)

        {

            Address = Address + 4;

        }

        else

        {

            Error_Handler();

        }

        i -= 4;

    }

// write

1

byte example –

does not work

   

while

(i > 0)

    {

      

if

(HAL_DATA_EEPROMEx_Program(TYPEPROGRAM_BYTE, Address, ubData[i]) == HAL_OK)

        {

            Address = Address + 1;

        }

        else

        {

            Error_Handler();

        }

        i -= 1;

    }

Thanks.
1 REPLY 1
Posted on September 15, 2014 at 10:55

Hi kosakovski.evgeni,

This API should work BYTES as it works with WORDS. The Address must be between DATA_EEPROM_BASE and DATA_EEPROM_END. Could you please activate the debug mode in order to check the validity of the input parameters by following the two steps below:
  1. In stm32l0xx_hal_conf.h, uncomment /* #define USE_FULL_ASSERT 1 */
  2. Add in your user code the following function:

    #ifdef USE_FULL_ASSERT

    /**

    * @brief Reports the name of the source file and the source line number

    * where the assert_param error has occurred.

    * @param file: pointer to the source file name

    * @param line: assert_param error line source number

    * @retval None

    */

    void assert_failed(uint8_t *file, uint32_t line)

    {

    /* User can add his own implementation to report the file name and line number,

    ex: printf(''Wrong parameters value: file %s on line %d
    
    '', file, line) */

    /* Infinite loop */

    while (1)

    {

    }

    }

    #endif

Please try to apply the suggested modifications and keep us informed about your finding. Regards.