EasyManuals Logo

ST STM32L0x3 User Manual

ST STM32L0x3
1043 pages
To Next Page IconTo Next Page
To Next Page IconTo Next Page
To Previous Page IconTo Previous Page
To Previous Page IconTo Previous Page
Page #83 background imageLoading...
Page #83 background image
RM0367 Rev 7 83/1043
RM0367 Flash program memory and data EEPROM (FLASH)
122
Any wrong key sequence will lock up FLASH_PECR until the next reset and generate a
hard fault. Idem if the master tries to write another register between the two key sequences
or if it uses the wrong key. A reading access does not generate an error and does not
interrupt the sequence. A hard fault is returned in any of the four cases below:
After the first write access if the PEKEY1 value entered is erroneous.
During the second write access if PEKEY1 is correctly entered but the value of
PEKEY2 does not match.
If there is any attempt to write a third value to PEKEYR (pay attention: this is also true
for the debugger).
If there is any attempt to write a different register of the memory interface between
PEKEY1 and PEKEY2.
When properly executed, the unlocking sequence clears PELOCK bit in the FLASH_PECR
register.
To lock FLASH_PECR and the data EEPROM again, the software only needs to set
PELOCK bit in FLASH_PECR. When locked again, PELOCK bit needs a new sequence to
return to 0.
For code example, refer to A.3.2: Locking data EEPROM and FLASH_PECR register code
example.
Unlocking the Flash program memory
An additional protection is implemented to write/erase the Flash program memory.
After a reset, the Flash program memory is no more accessible in write mode: PRGLOCK
bit is set in the FLASH_PECR register. A write access to the Flash program memory is
granted by clearing PRGLOCK bit.
The following sequence is used to unlock the Flash program memory:
Unlock the FLASH_PECR register (see the Unlocking the data EEPROM and the
FLASH_PECR register section).
Write PRGKEY1 = 0x8C9DAEBF to the FLASH_PRGKEYR register.
Write PRGKEY2 = 0x13141516 to the FLASH_PRGKEYR register.
For code example, refer to A.3.3: Unlocking the NVM program memory code example.
If the keys are written with PELOCK set to 1, no error is generated and PRGLOCK remains
at 1. It will be unlocked while re-executing the sequence with PELOCK = 0.
Any wrong key sequence will lock up PRGLOCK in FLASH_PECR until the next reset, and
return a hard fault. A hard fault is returned in any of the fou
r cases below:
After the first write access if the entered PRGKEY1 value is erroneous.
During the second write access if PRGKEY1 is correctly entered but the PRGKEY2
value does not match.
If there is any attempt to write a third value to PRGKEYR (this is also true for the
debugger).
If there is any attempt to write a different register of the memory interface between
PRGKEY1 and PRGKEY2.
When properly executed, the unlocking sequence clears the PRGLOCK bit and the Flash
program memory is write-accessible.

Table of Contents

Questions and Answers:

Question and Answer IconNeed help?

Do you have a question about the ST STM32L0x3 and is the answer not in the manual?

ST STM32L0x3 Specifications

General IconGeneral
BrandST
ModelSTM32L0x3
CategoryMicrocontrollers
LanguageEnglish

Related product manuals