2010-11-08 06:05 AM
printf over the SWO
2011-05-17 05:14 AM
I’m looking for a small example on how to printf over the SWO to the Keil IDE, I can do it by RS323 to a terminal, but how do I point it to the SWO instead of the UART, can someone please provide me with a small example or a link to where I can read about it. Thanks
Replace the semi-hosting routines, specifically the fputc() and _ttywrch() with routines that access the M3's debug channel. Something along the following lines, using the core_cm3 CMSIS Core Support package. #include <rt_misc.h> #pragma import(__use_no_semihosting_swi) struct __FILE { int handle; /* Add whatever you need here */ }; FILE __stdout; FILE __stdin; int fputc(int ch, FILE *f) { return (ITM_SendChar((uint32_t)ch)); } int fgetc(FILE *f) { return ((int)ITM_ReceiveChar()); } int ferror(FILE *f) { /* Your implementation of ferror */ return EOF; } void _ttywrch(int ch) { ITM_SendChar((uint32_t)ch); } void _sys_exit(int return_code) { label: goto label; /* endless loop */ }