2024-11-29 11:51 AM
Hi and thanks in advance !
My application uses a STM32G0B0 to control an LED driver through PWM among other things (pin (26)-PB14).
The device can receive commands and I have added an option to jump to bootloader through a special command to perform firmware updates through USB. This works well, however, the pin I use to control the PWM LED driver remains high while in the bootloader, which could cause the LED board to heat up too much.
I have tried to stop the timer and configure the pin low before jumping, and it works to pull the pin low right until the jump is actually made.
A pull-down resistor soldered between the PWM pin and GND did not change this behaviour either.
Could the bootloader be forcing this specific high ? What other options could there be to make sure it remains low while in the bootloader ?
Here is the current bootloader jump code, stripped of my attempts to turn off the pin before jumping :
void JumpToBootLoader() {
void (*SysMemBootJump)(void);
HAL_DeInit();
/* Disable all interrupts */
__disable_irq();
/* Disable Systick timer */
SysTick->CTRL = 0;
/* Set the clock to the default state */
HAL_RCC_DeInit();
/* Clear Interrupt Enable Register & Interrupt Pending Register */
for (uint32_t i=0;i<sizeof(NVIC->ICER);i++)
{
NVIC->ICER[i]=0xFFFFFFFF;
NVIC->ICPR[i]=0xFFFFFFFF;
}
/* Re-enable all interrupts */
__enable_irq();
/* /!\ THIS LINE IS REQUIRED TO REMAP MEMORY BY HAND BEFORE JUMPING /!\ */
SYSCFG->CFGR1 = 0x01;
SysMemBootJump = (void (*)(void))(*((uint32_t *)(0x1FFF0000 + 4)));
__set_MSP(*(__IO uint32_t *)0x1FFF0000);
SysMemBootJump();
}
Thanks in advance !
2024-11-29 12:04 PM
The explanation of boot mode behavior may be found in AN2606. Please Read The Fine Document.
2024-11-29 03:55 PM
Thanks a lot for pointing me to this document !
Indeed it mentions that the pin is used as SPI2 MISO in push-pull, pull-down mode, but set to 3.3V "on the bootloader start-up after SPI initialization as soon as the bit DMATx enable on SPI CR2 register is set to 0x1"
Seems like dead-end with this current pin, I will look into moving it to another one that is not used during the bootloader. I assume that pins not used specifically during the bootloader should be floating or hopefully weak enough that an external pull-down resistor should guarantee that it is low ?
Thanks again !