c - Printf output using UART in ARM Cortex-M3 microcontroller -


i have lpc1768 based board - landtiger (worth checking manual @ bottom). program use keil uvision4/72 lite , j-link edu segger. simple program interact joystick , diodes works fine, but...

i trying implement debug printf, can see printf output in keil "debug (printf) viewer" window. problem dont see output - think on right track because when run debugger can see trace:running @ bottom of window (before trace:no synchronization). unfortunately dont see in uart , debug output windows.

i've spent quite lot of time trying make work , appreciate help, thank ;)

my keil settings are:

project/options target/debug set j-link/j-trace cortex.

then inside it's settings have segger selected port:sw , max clock:10 mhz.

trace tab enabled 100mhz core clock , swo prescaler = 17 (which results in 5.882352mhz swo clock).

itm stimulus ports set enable:0xffffffff , privilege:0x0000000f

here parts of code:

define fosc 12000000

define fcclk (fosc * 8)

define fcco (fcclk * 3)

define fpclk (fcclk / 4)

define uart0_bps 115200

void uart0_init (void)

{

uint16_t usfdiv;

/* uart0 */

lpc_pincon->pinsel0 |= (1 << 4);/* pin p0.2 used txd0 (com0) */

lpc_pincon->pinsel0 |= (1 << 6);/* pin p0.3 used rxd0 (com0) */

lpc_uart0->lcr = 0x83;

usfdiv = (fpclk / 16) / uart0_bps;

lpc_uart0->dlm = usfdiv / 256;

lpc_uart0->dll = usfdiv % 256;

lpc_uart0->lcr = 0x03;

lpc_uart0->fcr = 0x06;
}

sending code:

int uart0_sendbyte (int ucdata)

{

while (!(lpc_uart0->lsr & 0x20)){};

return (lpc_uart0->thr = ucdata);

}

and fputc printf (it called - checked)

int fputc(int c, file *f)

{

if (c == '\n') {

uart0_sendbyte('\r');

}

return (uart0_sendbyte(c));

}

any ideas?

regards!

your fputc sends bytes directly uart, goes rs232 connector on board. if want see output of fputc, need connect cable between board , pc , see client such hyperterminal.

when talk trace capabilities, means adapter (j-link in case) creates high throughput communication between program , debugger , follows execution of program. there other debug functionalities. example if compile semihosting, program executes system calls (_write, _open, ...) intercepted debugger executes them on host machine.

so in experience either call printf, don't override fputc , compile semihosting, , expect output on debug window, or send uart, connect rs232 pc , see on hyperterminal.

i see found third method uses trace capabilities. believe semihosting option more general solution because can applied on setup doesn't have trace capabilities jtag (or swd) connection.


Comments

Popular posts from this blog

html - How to style widget with post count different than without post count -

How to remove text and logo OR add Overflow on Android ActionBar using AppCompat on API 8? -

javascript - storing input from prompt in array and displaying the array -