cancel
Showing results for 
Search instead for 
Did you mean: 

How to single stepping debug STM32F091

Mark Peter Vargha
Associate III
Posted on March 09, 2018 at 14:33

I have several STM32 CubeMX / HAL projects and I use EmBitz as IDE. All porjects working fine, including compilation and debugging. There are projects with STM32F103, STM32F205, STM32F207,STM32F405, STM32F429, STM32L476, etc. There is one exception: Execution single stepping is not working withSTM32F091 target. Always steps into timer interrupt and never get out. Is there a solution? Thanks.

Note: this post was migrated and contained many threaded conversations, some content may be missing.
9 REPLIES 9
T J
Lead
Posted on March 10, 2018 at 07:16

Its only a suggestion,  that you try turning off the Data and Instruction caches.

hopefully you would gain clues as to what is happening there..

Consider shortening the debug cable length..

Check the schematic circuitry on that particular board's  'F091 SWD interface..

There maybe some odd hardware configuration that needs attention.

Check the physical connector male and female parts, looking for connection issues.

Check the ground connection between the host PC and the board and the board's power supply.

You may have unwanted ground currents, it all depends on the Board's power supply.

Grounding to the PC would alleviate that issue.

Posted on March 10, 2018 at 08:20

This is an official STM32F091RC Nucleo board.

Posted on March 10, 2018 at 23:49

I use this board extensively, and my personal boards use this chip, there are no issues in any platform.

I haven't tried EmBitz, there may be your problem. or else try another board...

Posted on March 11, 2018 at 21:51

DBG_TIMx_STOP set for the timer in question in DBGMCU_APBy_FZ?

JW

Posted on March 12, 2018 at 05:35

This is a CubeMX generated HAL project. There is FreeRTOS and TIM2 is the time base.

There is a stm32f091xc.h header file, and there are these lines:

/****************** Bit definition for DBGMCU_APB1_FZ register **************/

&sharpdefine DBGMCU_APB1_FZ_DBG_TIM2_STOP_Pos (0U)

&sharpdefine DBGMCU_APB1_FZ_DBG_TIM2_STOP_Msk (0x1U << DBGMCU_APB1_FZ_DBG_TIM2_STOP_Pos) /*!< 0x00000001 */

&sharpdefine DBGMCU_APB1_FZ_DBG_TIM2_STOP DBGMCU_APB1_FZ_DBG_TIM2_STOP_Msk /*!< TIM2 counter stopped when core is halted */
Posted on March 12, 2018 at 08:37

Then set it in your program. It will stop the timer during debugging thus suppress further timer interrupts.

JW

Posted on March 12, 2018 at 11:06

I tried to put DBGMCU->APB1FZ |= DBGMCU_APB1_FZ_DBG_TIM2_STOP; at several places: the beginning and the end of init in main(), and into the start of the default task. No luck. Single stepping is iterating over and over here in stm32f0xx_it.c:

/**

* @brief This function handles TIM2 global interrupt.

*/

void TIM2_IRQHandler(void)

{

/* USER CODE BEGIN TIM2_IRQn 0 */

/* USER CODE END TIM2_IRQn 0 */

HAL_TIM_IRQHandler(&htim2);

/* USER CODE BEGIN TIM2_IRQn 1 */

/* USER CODE END TIM2_IRQn 1 */

}
Posted on March 12, 2018 at 12:02

Do you step inside HAL_TIM_IRQHandler() or are you trying to step over it? Does the handler clear the flag(s) causing the interrupt?

JW

Posted on March 12, 2018 at 12:20

No, I do not want to step into it.

If I manually stop execution, or it hits a breakpoint anywhere, it stops. OK. Then I click single step (go to next line) and the debugger jumps intoTIM2_IRQHandler instead of next line. I tried to click on step out, but it stopped again inTIM2_IRQHandler.