cancel
Showing results for 
Search instead for 
Did you mean: 

Ensure a pin is low while in bootloader

4lch
Associate II

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 !

1 REPLY 1
gbm
Lead III

The explanation of boot mode behavior may be found in AN2606. Please Read The Fine Document.

My STM32 stuff on github - compact USB device stack and more: https://github.com/gbm-ii/gbmUSBdevice