cancel
Showing results for 
Search instead for 
Did you mean: 

Debugging with STM32F401C Discovery

tgr
Associate II
Posted on November 27, 2013 at 11:42

Hi,

I am using a STM32F401C Discovery board with the L3GD20 project example and I wanted to use the Debug printf view to see what are the data coming from the gyroscope. I followed this tutorial from Keil to enable it but it isn't working:

http://www.keil.com/support/man/docs/ulink2/ulink2_trace_itm_viewer.htm

So I am asking if there is a way to use the Debug printf or not?

I also wanted to ask if there are soft examples using the accelerometer of the board.

Best regards!

Yann

#stm32f401c-discovery
19 REPLIES 19
Posted on November 29, 2013 at 10:07

Both uv4.7 and uv5, you don't find that a tad weird?

Honestly it still strikes me that you have the wrong pre-processor defines, which should be

USE_STDPERIPH_DRIVER,STM32F401xx

You've likely got multiple processors defined, and it's trying to instantiate multiple enum sections from an examination of the include file in questions, at the line number specified.

Tips, Buy me a coffee, or three.. PayPal Venmo
Up vote any posts that you find helpful, it shows what's working..
tgr
Associate II
Posted on November 29, 2013 at 10:59

It's the preprocessor symbols define I already got.

andiob
Associate II
Posted on November 29, 2013 at 16:45

I recently bought this board and encountered the same problem while preparing an empty project. The fact is that when you select the ''STM32F401VC'' as the target a preprocessor, define STM32F40XX is automatically put in the compiler command and cannot be edited. The device header file tells to use ''STM32F401xx'' for this processor but when STM32F40XX is defined, STM32F40_41xxx get chosen. I managed to compile and run program that blink a led using the STM32F40_41xxx define instead of

of

the recommended

. A way of solving the problem is to remove this lines from stm32f4xx.h and use the correct processor definition ( i haven't tested this solution yet but i did a quick search and STM32F40XX is used only there

/* Old STM32F40XX definition, maintained for legacy purpose */
#ifdef STM32F40XX
#define STM32F40_41xxx
#endif /* STM32F40XX */

I then followed

http://www.keil.com/appnotes/files/apnt_pdf

application note but i was unable to use logic analyzer and event viewer, i havent tryed the printf yet.
andiob
Associate II
Posted on November 30, 2013 at 12:49

After doing some research i found that the files that come from st site also have problem in pll configuration because are written for a 25mhz crystal and the discovery board use a 8mhz. Even after the resolution of this issue i'm still unable to use logic analyzer , event viewer or printf and in the thebug window i see the message ''Trace no synchronization''

Posted on November 30, 2013 at 13:23

This is normally addressed by a project local copy of stm32f4xx_conf.h which is pulled in by stm32f4xx.h (USE_STDPERIPH_DRIVER) or stm32f401_discovery.h, and a local copy of system_stm32f4xx.c with the correct PLL settings.

See project  construction in STM32F401-Discovery_FW_V1.0.0\Projects\Peripheral_Examples\ADC_DMA

If the board is in fact running at 84 MHz, and the trace clock is set to this, the SWV output works. I'm in transit now otherwise I'd ZIP up the project to demonstrate.

If the clock is of concern output it via one of the MCO or TIM pins and physically confirm.
Tips, Buy me a coffee, or three.. PayPal Venmo
Up vote any posts that you find helpful, it shows what's working..
andiob
Associate II
Posted on December 02, 2013 at 09:22

I used the config files you said but still i'm unable to use the debugging features. Tomorrow i'll test the board with a scope to see if clock is right or not.

Anyway if is possible for you to upload your code i could compare with mine, maybe i left something behind

Thranks a lot
Posted on December 02, 2013 at 18:12

Building with 4.70 with library and project arranged thusly

C:\Keil\ARM\Examples\ST\STM32F401-Discovery_FW_V1.0.0\Projects\SWV-DEMO

https://drive.google.com/file/d/0B7OY5pub_GfITVdTbF9iX0dLSkE/edit?usp=sharing

0690X00000605TcQAI.png

0690X00000605WQQAY.png

Tips, Buy me a coffee, or three.. PayPal Venmo
Up vote any posts that you find helpful, it shows what's working..
tgr
Associate II
Posted on December 03, 2013 at 10:12

Hi, thanks for all your replies and for your examples.

@sires : When putting in comments the line you mentionned, I can properly run my project! Thanks a lot!

@clive1 : I can't understand why you select a STM32F405OE device when it should be a STM32F401VC for the disco and why your Xtal is at 8.0MHz instead of 84MHz.

Posted on December 03, 2013 at 14:28

The CPU/Xtal selection are not critical, the memory allocation is important to the linker, and the CPU type (Cortex-M4) to the compiler.

The Xtal on the Discovery board is 8 MHz. It is the clock setting in the Debug/Trace pane that is critical to SWV support.

The template project uses STM32F4_256KB, as of 4.71a there doesn't appear to be explicit support for F401 parts, they are nevertheless usable.
Tips, Buy me a coffee, or three.. PayPal Venmo
Up vote any posts that you find helpful, it shows what's working..
andiob
Associate II
Posted on December 05, 2013 at 16:24

T

he curious thing

is that now trace featured passed from not working to working sometimes and i can't understand why