2017-04-22 04:10 AM
Hi, I'm having an issue on STM32L151RC with HAL_FLASH_OB_Launch(), simplifying:
if (HAL_FLASH_OB_Unlock() == HAL_OK)
{ HAL_FLASH_OB_Launch(); while (1);}MCU seems to fall in an undefined state.
Certainly GPIO peripherals reset, beacause a pin configured as output, after launch, turns into hi-z input state (its default at reset), but CPU doesn't, because the 1st ever executed instruction at reset, in startup_stm32l151xc.s, is this:Reset_Handler:
bl test_resetand test_reset() is never reached.
void test_reset(void)
{// led_r_Pin PORTB.6// led_g_Pin PORTB.7// led_b_Pin PORTB.8__HAL_RCC_GPIOB_CLK_ENABLE();
(*GPIOB).MODER = ((*GPIOB).MODER & ~0b00000000000000111111000000000000UL) | 0b00000000000000010101000000000000UL;
(*GPIOB).ODR = 0b00000000000000000000000000000000UL;if (HAL_IS_BIT_SET((*RCC).CSR, RCC_CSR_OBLRSTF))
{ // OBL reset occurred, toggle blue led foreverwhile (1)
tgl_led_b(); // toggle port B pin 8 } else { // non-OBL reset occurred, toggle red led for a while, then exitDWORD timeout = 0xFFFFF;
do {
tgl_led_r(); // toggle port B pin 6 } while (timeout--);// exit
}__HAL_RCC_GPIOB_CLK_DISABLE();
}Any idea?
Thanks#oblrstf #option-bytes #hal_flash_ob_launch #obl_launch #obl-launch #options-bytes-loading-reset-flag #obl-reset2017-04-22 06:36 AM
Calling HAL_RCC_DeInit() before HAL_FLASH_OB_Launch() seems to be a valid workaround.