cancel
Showing results for 
Search instead for 
Did you mean: 

How use Serial Wire Output ?

asrock70
Associate II
Posted on February 23, 2014 at 10:25

Can you advise

some

example that

would use the

SWO

port

for

output from the

program

in

UART

mode

?

Ideal

for

STM32F1

and

MDK

-ARM

1 REPLY 1
Posted on February 23, 2014 at 14:48

Make sure to set up the trace mode with the correct processor frequency, and checked options

http://www.keil.com/download/files/labst.pdf

The following allows putchar/printf to function:

#include <
stdio.h
>
#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)
{
ITM_SendChar(ch);
return(ch);
}
int fgetc(FILE *f)
{
char ch;
ch = 1;
return((int)ch);
}
int ferror(FILE *f)
{
/* Your implementation of ferror */
return EOF;
}
void _ttywrch(int ch)
{
ITM_SendChar(ch);
}
void _sys_exit(int return_code)
{
label: goto label; /* endless loop */
}

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