cancel
Showing results for 
Search instead for 
Did you mean: 

Option bytes programming STM32H7

DKlep.1
Associate

Hi, I want to program the brownout in code:

void setBrownout (uint32_t level) {

   FLASH_OBProgramInitTypeDef OBInit;

   HAL_FLASHEx_OBGetConfig(&OBInit);

   if (OBInit.BORLevel == 0) { // not programmed yet

      OBInit.BORLevel = level;

      OBInit.OptionType = OPTIONBYTE_BOR;

      if(HAL_FLASH_Unlock() == HAL_OK) {

         if(HAL_FLASH_OB_Unlock() == HAL_OK) {

         //   if(HAL_FLASHEx_OBErase() == HAL_OK) {

               HAL_FLASHEx_OBProgram(&OBInit);

               if(HAL_FLASH_OB_Lock() == HAL_OK) {

                  HAL_FLASH_Lock();

                  HAL_FLASH_OB_Launch();

               }

         //   }

         }

      }

   }

   HAL_FLASHEx_OBGetConfig(&OBInit); // check

}

I see all FLASH registers being updated. HAL_FLASH_OB_Launch() waits until the busy flag is cleared, but this flag isnt even set. Readout of the BORLevel stays zero.

What am i missing?

Dig

0 REPLIES 0