cancel
Showing results for 
Search instead for 
Did you mean: 

My code works when stepping in debug only, does not work in run mode

TombrownBottom
Associate II

I have an STM32F407 Discovery board. My project works fine using the dicovery board.

Now it is time to move it to my own PCB, using a STM32F405.

As a board "bring up" I tried to run a simple LED toggle program. When I flash the program I get a Download verified successfully message.

It does not work unless I step through it in debug mode. In run mode the output pin for the LED stays high. If I add a variable and increment it every time the LED toggles I can see it incrementing normally in debug mode.

I have an external resonator crystal at 8MHz. I can see it working at 8 MHz on the scope.

I have a 10K resistor pulling BOOT0 to ground. The two VCaps are present. A 10k resistor pulls NRST up to 3.3v rail.

All power and grounds ok with decoupling caps.

I have checked all settings in my .ioc file. Cant see any issues. (The settings are the same as for my discovery board program that works correctly).

Im sure one of you can help.

 

Thanks in advance...

2 REPLIES 2

So code probably is running..

Your code would be only thing turning on 8 MHz

Instrument Error_Hander() and HardFault_Handler() so you know if it ends up there. 

Do you have a UART you can use? Different LEDs?

SysTick needs to be working for delays to function. You need a delay to see LEDs toggling.

Can you toggle a GPIO/LED from a TIM pin or TIM IRQ Handler?

Tips, Buy me a coffee, or three.. PayPal Venmo
Up vote any posts that you find helpful, it shows what's working..

Hi,

How do I implement: Instrument Error_Hander() and HardFault_Handler() so you know if it ends up there. 

Im using an oscilloscope to monitor the output pin, so no LEDS required.

Why do I need a UART?

I call HAL_Init(); in the main function so the Systick will be running.

Ive never done (toggle a GPIO/LED from a TIM pin or TIM IRQ Handler). I need help with this one.