cancel
Showing results for 
Search instead for 
Did you mean: 

printf is displaying Junk characters using STM32CudeIDE ,STM32F46NG board ,QSPI_perfs Project

PKuma.151
Associate II

Hi All,

I have opened the shipped QSPI_perfs proejct and modified the syscalls.c write function to use the below code

//Debug Exception and Monitor Control Register base address
#define DEMCR        			*((volatile uint32_t*) 0xE000EDFCU )
 
/* ITM register addresses */
#define ITM_STIMULUS_PORT0   	*((volatile uint32_t*) 0xE0000000 )
#define ITM_TRACE_EN          	*((volatile uint32_t*) 0xE0000E00 )
 
void ITM_SendChar(uint8_t ch)
{
 
	//Enable TRCENA
	DEMCR |= ( 1 << 24);
 
	//enable stimulus port 0
	ITM_TRACE_EN |= ( 1 << 0);
 
	// read FIFO status in bit [0]:
	while(!(ITM_STIMULUS_PORT0 & 1));
 
	//Write to ITM stimulus port0
	ITM_STIMULUS_PORT0 = ch;
}

I have also chnaged the ITM settings accordingly as per the video. I have modified the main.c to remove LCD display settings/calls.

Attached the modified project for reference. Let me know if I am missing anything here.

Any help would be highly appreciated.

Thanks,

Praveen.

3 REPLIES 3

ITM/SWV output that is corrupted suggests a mismatch in understanding of the core's clock on the host side, and the reality on the target.

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

I did suspect it is something related to clock. Reason is as I change the SWV clock in Debugger configurations I have seen faster display of more junk charactes.

Is there a way to fix this.

PIvan.9
Associate II

I had the same issue, but with NUCLEO-L476RG board. What helped me is to change the Core Clock frequency by 0.1MHz (go to Run->Debug Configurations->Debugger). I suppose that the internal oscillators can drift after some time, so maybe we need to blindly compensate for it.