cancel
Showing results for 
Search instead for 
Did you mean: 

STM32L081KZ,Dual-Boot,TIMER2 upgrade interrupt is valid in bank1, switch to bank2 is invalid! then switch to bank1 is valid???how

Ewei.765
Associate

code 1: start:

int main(void)

{

 /* USER CODE BEGIN 1 */

 LL_SYSCFG_SetRemapMemory(LL_SYSCFG_REMAP_FLASH);

 LL_SYSCFG_SetFlashBankMode(LL_SYSCFG_BANKMODE_BANK2);

……

}

code 2:switch:

void switchFlashBankToUpgrade(uint16_t BootBank)

{

 HAL_FLASH_OB_Unlock();

 HAL_FLASHEx_OBGetConfig(&OB_Init_t);

 HAL_FLASHEx_AdvOBGetConfig(&OBAdv_Init_t);

 OB_Init_t.OptionType = OPTIONBYTE_BOOT_BIT1;//OPTIONBYTE_RDP | | OPTIONBYTE_WRP;

// OB_Init_t.RDPLevel = OB_RDP_LEVEL_0;

// OB_Init_t.WRPState = OB_WRPSTATE_DISABLE;

// OB_Init_t.WRPSector = OB_WRP_AllPages;

// OB_Init_t.WRPSector2 = OB_WRP2_AllPages;

 OB_Init_t.BOOTBit1Config = OB_BOOT_BIT1_RESET;

 HAL_FLASHEx_OBProgram(&OB_Init_t);

 OBAdv_Init_t.OptionType = OPTIONBYTE_BOOTCONFIG;// | OPTIONBYTE_PCROP;

 OBAdv_Init_t.BootConfig = BootBank;

// OBAdv_Init_t.PCROPState = OB_PCROP_STATE_DISABLE;

// OBAdv_Init_t.PCROPSector = OB_PCROP_AllPages;

// OBAdv_Init_t.PCROPSector2 = OB_PCROP2_AllPages;

 HAL_FLASHEx_AdvOBProgram(&OBAdv_Init_t);

 printf("DEBUG_FLASH_OB:->> Ready to reload OB!\r\n");

 HAL_FLASH_OB_Launch();

 HAL_FLASH_OB_Lock();

}​

0 REPLIES 0