2018-06-21 03:07 PM
Looking for assistance on getting printf() working with the Nucleo-L452RE-P board (MB1319 B-01) using the built-in ST-Link (not UART, and not semi-hosting). I get output in the console, but the text doesn't match. E.g. if I call 'printf('abc\n')', I get ��� in the output.
To Produce:
I created a project in CubeMX, set Debug to Trace Asynchronous Sw, set SYSCLK and HCLK to 16 MHz, and generated a project for TrueStudio.
In TrueStudio, I created syscalls.c, and modified the _write() function to use ITM_SendChar(). In the debugger configuration, I made sure the Interface was set to SWD, enabled Serial Wire Viewer, and set the Core Clock to 16 MHz.
I started a debug session, configured the SWV Console to use ITM Stimulus Ports 0, hit Start Trace, and then Resume (start execution).
Stepping through code and checking variables in the Expressions window works fine.
Additionally, I tried printf with the L4 board and IAR Embedded Workbench, and that displayed the same problem as TrueStudio.
As a sanity check, I tried the procedure with a Nucleo F103RB board (MB1136 C-01), and received the expected output with printf(), so that worked fine.
Any advice on how to debug this issue?
#printf #stm32l42018-06-21 04:51 PM
Well got a bunch of L4's working with SWV output. Would recommend double checking the solder bridges are made.
Primary method of troubleshoot these things are getting the USART-VCP up, dumping internal settings and sending to both VCP and SWV.
Snarling up the data suggests the clock being off. The L4 NUCLEO usually clock from the MSI, solder bridges to the 8 MHz source disconnected.
I use the ST-LINK SWV viewer and Keil as reference points.
2018-06-21 05:25 PM
This was built for a NUCLEO-L476RG, runs at 80 MHz, outputs via SWV and USART-VCP at 115200 8N1
Nucleo L476RG
Core=80000000, 80 MHz CPUID 410FC241 DEVID 415 REVID 1007 Cortex M4 r0p1 STM32L475xx, L476xx or L486xx C0000000 00000000 00000000 10110021 11000011 00000000 FPU-S Single-precision only HCLK=80000000 APB1=80000000 APB2=80000000 Infinite loop...Should work on other L4 NUCLEO-64 boards
________________ Attachments : NUCLEO64-L4-SWV-001.hex.zip : https://st--c.eu10.content.force.com/sfc/dist/version/download/?oid=00Db0000000YtG6&ids=0680X000006HxTv&d=%2Fa%2F0X0000000aye%2FC2FCvxkRtTkwf40b09Y4HLc6_ec8xkNYCK5OYa5LYWI&asPdf=false2018-06-22 08:29 AM
The code you posted did provide output to the serial console and Serial Wire Viewer. I'm going to try and replicate your project.
Edit 1: My project is now working. The issue was with the HSI RC clock. If I switch to MSI RC set to 16000 KHz, I get between 15.9 MHz and 16.1 MHz at MCO, measured with an oscilloscope. printf() via SWV and Uart_Tx work fine. If I go back to HSI RC at 16 MHz, the oscilloscope reads 14.6 MHz and 14.8 MHz. I get junk on the SWV and serial console.
2018-06-22 10:12 AM
I'm using MSI Range 6, 4 MHz, into the PLL