Why isn’t my printf output showing on the SWV ITM console for STM32F401CDU6?
Good day @everyone
I am trying to use the printf and the SWV for stm32f401CDU6 board
wrote my code on the stm32cubeIDE (main.c)
I have pasted the ITM funtionality code to the syscalls.c and have done the changes needed at the write function
I have done my debugging using 84MHz(which is the board frequency)
yet my printf code is not yet played on the SWV ITM date console(i have also done the port selection)
what can I do next
25 Replies
People may need to see your code, this issue always catches me off in new projects have to spend an hour and it works
ok
i didn't use the graphic approach
In
syscalls.c
file you need to add few more lines of code at the top. Here it is
/////////////////////////////////////////////////////////////////////////////////////////////////////////
// Implementation of printf like feature using ARM Cortex M3/M4/ ITM functionality
// This function will not work for ARM Cortex M0/M0+
// If you are using Cortex M0, then you can use semihosting feature of openOCD
/////////////////////////////////////////////////////////////////////////////////////////////////////////
//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 added this line of code
the output is not display
Also, confirm if in debugger settings you have setup properly especially to enable SWV & Clock settings. In your case may change for different clock speed if you're not running @ 16MHz
Yes I have done that; enable the SWV and set clock speed to 84
This code seems like missing pointers to hold memory addresses. Please copy paste my suggested lines of code or compare both carefully. Following part of your code
ok
I have also used your suggested code line
do you think the problem could e from the hardware
And its my first time using this board
Unfortunately, I never used STM32 BlackPill. So it'll be difficult for me to say anything
whether it's an issue with stlinkv2 clones or something
ok
thanks for your effort
Welcome!
@Okpara Elvis did you update your clone st link programmer firmware ? If yes than u have bricked it
yes did
this there anything I can do about that?
but the upgrade was successful
yeah but few people have reported it, after the new 1.17 update if you update your firmware of the Chinese clone programmer via the stm32 cube programmer , it will be rendered it useless.
try using another or a new clone
Recently, I'm using official STLINK-V3MODS programmer and debugger at just $ 9.30 ~ ₹ 792.00. You can even solder this programmer & debugger on a custom motherboard/pcb for field update!
@Okpara Elvis is it solved?
or should I help?
after seeing the picture of your stlink sadly it doesn't have SWO capality
you need something like this to use that
see this has a SWO pin
now you can change your stlink or I can give you another suggestions that use printf via UART
if you need any help please mention me