2019-05-23 03:19 AM
Hello,
I would like to use the ITM Printf directly inside a Console of STM32CubeIDE but It doesn't work on my side.
I was able to display a character inside a "SWC ITM data Console" by using ITM_SendChar(). But I have the next issues:
- For using printf, I read somewhere that I have to change the _write function inside syscalls.c like this:
__attribute__((weak)) int _write(int file, char *ptr, int len)
{
int DataIdx;
for (DataIdx = 0; DataIdx < len; DataIdx++)
{
ITM_SendChar( *ptr++ );
}
return len;
}
But even with this change, printf doesn't work.
- It seems that it is mandatory to click on "Start Trace" on "SWV ITM Data Trace" each time I want to use the console display. So I have to do it every time I run a new debug session. There is a easy way to enable by default the "Start Trace " at each debug session?
Thansk for your help.
2019-09-03 12:29 PM
Here it worked when I put the following instruction at the beginning of the main.c file:
#ifdef _GNUC_
/* With GCC/RAISONANCE, small printf (option LD Linker->Libraries->Small printf
set to 'Yes') calls __io_putchar() */
#define PUTCHAR_PROTOTYPE int __io_putchar(int ch)
#else
#define PUTCHAR_PROTOTYPE int fputc(int ch, FILE *f)
#endif / _GNUC_ /
Hope it helps.
Best regards,
Flavio
2019-09-04 12:55 AM
Thanks a lot for your help.
I can't test it now, but I will do it.
2020-01-04 09:01 AM
I think this answer deserves better explanation.
Well imho there are 3 options:
If you choose 1 and the code is generated again then your changes are lost.