2020-08-23 09:16 AM
Hi, I have designed a small project on the STM32F042F6Px MCU, and wrote a piece of software for it. Then I tried to run it outside of the debugger, and realized it won't boot. I've spent many hours on it already, and now I run out of ideas. It looks like no code is executed at all if the MCU is just powered (does not matter if STlink cable is connected or not). Everything runs fine if I power it on, and then choose "Debug" in Atollic.
I have stripped down the program of everything. No, really. I have even disabled everything in the startup file, so that only this remained:
Reset_Handler:
bl main
My main function is just this:
int main(void)
{
__HAL_RCC_GPIOB_CLK_ENABLE();
GPIOB->MODER |= 0b01 << (8*2);
GPIOB->BSRR = GPIO_PIN_8;
while (1) { };
}
The result is that the PB8 line goes high when the app is run from the debugger, and is floating when run outside of debugger.
I have even soldered another chip in case that one was faulty. No change.
I have over 5 years of experience with various STM32 MCUs, but have never seen anything like this.
Solved! Go to Solution.
2020-08-23 11:47 AM
The other likely option is that BOOT0 is not pulled down. Custom board?
2020-08-23 11:00 AM
Can it be that the program is built to execute in RAM?
(no offence... it happens sometimes)
-- pa
2020-08-23 11:47 AM
The other likely option is that BOOT0 is not pulled down. Custom board?
2020-08-23 12:35 PM
BOOT pins or Option Byte settings.
2020-08-23 01:00 PM
You are all right :)
I have thought about the BOOT0 thing, but assumed that this MCU didn't have the pin (it's not marked in any way in CubeMX, and I haven't thought to cross-check the docs).
And the pin is pulled up on the board of course, so unchecking nBoot0_SW_Cfg did the trick.
THANK YOU!