EEPROM Memory Library

This library provides routines for accessing microcontroller's (internal) EEPROM memory. Only the STM32L series of MCU have internal EEPROM memory.

Library Routines

EEPROM_Unlock

Prototype

void EEPROM_Unlock();

Description

This routine will unlock the EEPROM control register access.

This routine is valid only for STM32L devices.

Parameters

None.

Returns

Nothing.

Requires

Nothing.

Example
EEPROM_Unlock();
Notes

This routine is valid only for STM32L devices.

EEPROM_lock

Prototype

void EEPROM_lock();

Description

This routine will lock the EEPROM control register access.

This routine is valid only for STM32L devices.

Parameters

None.

Returns

Nothing.

Requires

Nothing.

Example
EEPROM_lock();
Notes

This routine is valid only for STM32L devices.

It is recommended that EEPROM lock is performed right after the EEPROM write is finished to avoid any unwanted subsequent EEPROM writing.

EEPROM_EraseWord

Prototype

unsigned long EEPROM_EraseWord(unsigned long Address);

Description

This routine will erase a word (32-bit) from the specified EEPROM address.

This routine is valid only for STM32L devices.

Parameters
  • Address: Specifies the address from which the EEPROM data will be erased. It has to be in the EEPROM address range or else the result can be unpredictable.
Returns
  • EEPROM memory status. The returned value can be:
    • 0 : EEPROM_COMPLETE,
    • 1 : EEPROM_BUSY,
    • 2 : EEPROM_ERROR_PROGRAM,
    • 3 : EEPROM_ERROR_WRP
    • 4 : EEPROM_ERROR_OPERATION.
Requires

Requires unlock procedure to be performed afterwards.

Example
status = EEPROM_EraseWord(0);
Notes

This routine is valid only for STM32L devices.

The address has to be in the EEPROM address range or else the result can be unpredictable.

EEPROM_Write_Word

Prototype

unsigned long EEPROM_Write_Word(unsigned long Address, unsigned long lData);

Description

Writes a word (32-bit) at a specified address. The address has to be in the EEPROM address range or else the result can be unpredictable.

This routine is valid only for STM32L devices.

Parameters
  • Address:: specifies the address to be programmed.
  • lData: specifies the data to be programmed.
Returns
  • EEPROM memory status. The returned value can be:
    • 0 : EEPROM_COMPLETE,
    • 1 : EEPROM_BUSY,
    • 2 : EEPROM_ERROR_PROGRAM,
    • 3 : EEPROM_ERROR_WRP
    • 4 : EEPROM_ERROR_OPERATION.
Requires

Requires unlock procedure to be performed afterwards.

Example
status = EEPROM_Write_Word();
Notes

This routine is valid only for STM32L devices.

The address has to be in the EEPROM address range or else the result can be unpredictable.

EEPROM_Write_HalfWord

Prototype

unsigned long EEPROM_Write_HalfWord(unsigned long Address, unsigned int lData);

Description

Writes a half word (16-bit) at a specified address. The address has to be in the EEPROM address range or else the result can be unpredictable.

This routine is valid only for STM32L devices.

Parameters
  • Address:: specifies the address to be programmed.
  • lData: specifies the data to be programmed.
Returns
  • EEPROM memory status. The returned value can be:
    • 0 : EEPROM_COMPLETE,
    • 1 : EEPROM_BUSY,
    • 2 : EEPROM_ERROR_PROGRAM,
    • 3 : EEPROM_ERROR_WRP
    • 4 : EEPROM_ERROR_OPERATION.
Requires

Requires unlock procedure to be performed afterwards.

Example
status = EEPROM_Write_HalfWord();
Notes

This routine is valid only for STM32L devices.

The address has to be in the EEPROM address range or else the result can be unpredictable.

EEPROM_Write_Byte

Prototype

unsigned long EEPROM_Write_Byte(unsigned long Address, unsigned char lData);

Description

Writes a byte (8-bit) at a specified address. The address has to be in the EEPROM address range or else the result can be unpredictable.

This routine is valid only for STM32L devices.

Parameters
  • Address:: specifies the address to be programmed.
  • lData: specifies the data to be programmed.
Returns
  • EEPROM memory status. The returned value can be:
    • 0 : EEPROM_COMPLETE,
    • 1 : EEPROM_BUSY,
    • 2 : EEPROM_ERROR_PROGRAM,
    • 3 : EEPROM_ERROR_WRP
    • 4 : EEPROM_ERROR_OPERATION.
Requires

Requires unlock procedure to be performed afterwards.

Example
status = EEPROM_Write_Byte();
Notes

This routine is valid only for STM32L devices.

The address has to be in the EEPROM address range or else the result can be unpredictable.

Library Example

Copy Code To ClipboardCopy Code To Clipboard

Copyright (c) 2002-2012 mikroElektronika. All rights reserved.
What do you think about this topic ? Send us feedback!
Want more examples and libraries? 
Find them on LibStock - A place for the code