cancel
Showing results for 
Search instead for 
Did you mean: 

STM32CubeIDE

ADębs.1
Senior

What is the difference between HAL_FLASH_Lock and HAL_FLASH_OB_Lock

Andrzej

1 ACCEPTED SOLUTION

Accepted Solutions
Peter BENSCH
ST Employee

You will find the answer in HAL and the reference manual:

  • Lock and Unlock the FLASH interface using HAL_FLASH_Unlock() and HAL_FLASH_Lock() functions
  • Lock and Unlock the option bytes using HAL_FLASH_OB_Unlock() and HAL_FLASH_OB_Lock() functions

HAL_FLASH_Lock  locks FLASH Registers access using SET_BIT(FLASH->CR, FLASH_CR_LOCK);

HAL_FLASH_OB_Lock locks FLASH Option Byte Registers access using SET_BIT(FLASH->CR, FLASH_CR_OPTLOCK);

Please read the description for the LOCK and OPTLOCK bits in the reference manual under section Flash control register (FLASH_CR).

Regards

/Peter

In order to give better visibility on the answered topics, please click on Accept as Solution on the reply which solved your issue or answered your question.

View solution in original post

1 REPLY 1
Peter BENSCH
ST Employee

You will find the answer in HAL and the reference manual:

  • Lock and Unlock the FLASH interface using HAL_FLASH_Unlock() and HAL_FLASH_Lock() functions
  • Lock and Unlock the option bytes using HAL_FLASH_OB_Unlock() and HAL_FLASH_OB_Lock() functions

HAL_FLASH_Lock  locks FLASH Registers access using SET_BIT(FLASH->CR, FLASH_CR_LOCK);

HAL_FLASH_OB_Lock locks FLASH Option Byte Registers access using SET_BIT(FLASH->CR, FLASH_CR_OPTLOCK);

Please read the description for the LOCK and OPTLOCK bits in the reference manual under section Flash control register (FLASH_CR).

Regards

/Peter

In order to give better visibility on the answered topics, please click on Accept as Solution on the reply which solved your issue or answered your question.