cancel
Showing results for 
Search instead for 
Did you mean: 

STM32 CUBEMX SYS Debug Settings

William chang
Associate III
Posted on March 04, 2018 at 07:11

Here is the SYS debug settings Here is what CubeMX did. My questions is: 0690X00000609uHQAQ.png 0690X00000609oyQAA.png

I use Serial Wire and Trace Synchro Sw (4 bits) most.

Here is the SYS debug settings Here is what CubeMX did. My questions is:

Here is the SYS debug settings Here is what CubeMX did. My questions is:

In Serial Wire mode IS: INTrace Synchro Sw (4 bits)IS:

__HAL_RCC_AFIO_CLK_ENABLE();

__HAL_AFIO_REMAP_SWJ_NOJTAG();

__HAL_RCC_GPIOA_CLK_ENABLE();

In Serial Wire mode IS: INTrace Synchro Sw (4 bits)IS:

__HAL_RCC_AFIO_CLK_ENABLE();

__HAL_AFIO_REMAP_SWJ_NOJTAG();

__HAL_RCC_GPIOA_CLK_ENABLE();

__HAL_RCC_GPIOE_CLK_ENABLE();

Here is the SYS debug settings Here is what CubeMX did. My questions is:

It's necessary to do those job in main() ?

I think the right way is to set up configuration before the program is running.

0690X00000609ozQAA.png

and I right ?

Note: this post was migrated and contained many threaded conversations, some content may be missing.
9 REPLIES 9
Posted on March 04, 2018 at 09:09

I wonder what is the underlying problem here. You cannot debug the app before entering the main() code?

You shown that the app is ran from RAM - does it matter here?

Posted on March 04, 2018 at 09:37

It doesn't matter about run in flash or ram. it is not in the case

I was thinking.

Our debugger can function correctly before we run into mian().

and we debug the first beginning place is  reset handler

0690X00000609uWQAQ.png

but CUBEMX initialize the debug access port  in the main() function.

I don't understand why to do that.

Posted on March 04, 2018 at 09:43

I guess they initialise pins in the unified way  - the same way as the do for regular non-SWD pins.

Right, whatever is done before main() cannot be accessed through the debugger.

Posted on March 04, 2018 at 10:04

0690X00000609sHQAQ.png

No, we can debug before main()! even though none of the clock (AFIO or GPIOA)  is disabled.

Maybe all is handle by KEIL under hook. 

Posted on March 04, 2018 at 10:18

Taken from F1 Reference Guide.

Bits 26:24 SWJ_CFG[2:0]: Serial wire JTAG configuration

These bits are write-only (when read, the value is undefined). They are used to configure the SWJ and trace alternate function I/Os. The SWJ (Serial Wire JTAG) supports JTAG or SWD access to the Cortex® debug port. The default state after reset is SWJ ON without trace. This allows JTAG or SW mode to be enabled by sending a specific sequence on the JTMS / JTCK pin.
Posted on March 04, 2018 at 10:47

This was not the answer. 

Why CUBEMX enable the GPIOA Clock and AFIO Clock. the Serial Debug can work without none to those clocks are enabled.

0690X00000609uXQAQ.png

something under control by keil debugger. I need to dig in more

Posted on March 04, 2018 at 18:55

Why CUBEMX enable the GPIOA Clock and AFIO Clock. the Serial Debug can work without none to those clocks are enabled.

It enables these clocks not for debugger, but because GPIOA pins and alt. functions are needed for something else.

-- pa

Posted on March 04, 2018 at 23:56

For what?

William chang
Associate III
Posted on March 06, 2018 at 00:48

0690X00000609wDQAQ.png

uVision debugger take control of these register. I don't know why CUBEMX doing its configuration it the main(), they can just change the pin color to green and not doing anythingin the mian(). It also freeze me with my trace configuration. Please refer to my tracing with stm32 question.

https://community.st.com/0D50X00009XkXxbSAF

Thanks for your attention.