Quality RTOS & Embedded Software

 Real time embedded FreeRTOS RSS feed 
Quick Start Supported MCUs PDF Books Trace Tools Ecosystem TCP & FAT




Loading

Directing the printf stream

Posted by Billy Rafferty on April 14, 2008
Hi there,

This is probably a very silly question, but I have been unable to figure it out.

I am using the ARM7_AT91SAM7X256_Eclipse demo and I want to use simple printf statements to help me debug my program. How can I use the printf function it to write to one of the serial ports? Must I write my own implantation of putchar() etc to implement this functionality, or has this low level stuff been included with the OS?

Many thanks,

Billy

RE: Directing the printf stream

Posted by Mark Meade on April 15, 2008
http://www.arm.com/support/faqdev/3824.html

Take a look at "retarget.c"... I was able to use this file to get stdio printf's to the debug serial port.

You need to implement two functions:

char UART_read(void);
void UART_write(char);

My implementation looks something like this:
/*-----------------------------------------------------------*/
void UART_write(char x)
{
xSerialPutChar( debugComPortHandle, x, mainUART_BLOCK_TIME );
}

/*-----------------------------------------------------------*/
char UART_read(void)
{
signed portCHAR rx;

if ( xSerialGetChar( debugComPortHandle, &rx, mainUART_BLOCK_TIME ) == pdTRUE )
{
return rx;
}
else
{
return NULL;
}
}

where "debugComPortHandle" is initialized as follows:

debugComPortHandle = xSerialPortInitMinimal( 115200, 100 );

This worked for me, but it was compiled using the latest Keil toolchain. I'm not sure if it will work with the Eclipse demo, but hopefully this points you in the right direction.

-- Mark



RE: Directing the printf stream

Posted by Billy Rafferty on April 16, 2008
Hi Mark,

I had a strange feeling I was going to have to implent a few functions.

Many thanks for the advice.

Cheers,

Billy

RE: Directing the printf stream

Posted by Çağlar Akyüz on April 16, 2008
For gcc you need to modify syscalls.c file and call your serial write/send routine there. I guess
you know this already :)

Another possibility is to use sprintf instead printf in your debug macros. Then you can send
that buffer via your serial,usb,ethernet,etc "send" functions, at least this is what I'm doing
now. Just in case...

Regards,
Caglar


[ Back to the top ]    [ About FreeRTOS ]    [ Sitemap ]    [ ]




Copyright (C) Amazon Web Services, Inc. or its affiliates. All rights reserved.

Latest News

FreeRTOS kernel V10 is available for immediate download. Now MIT licensed.


FreeRTOS Partners

ARM Connected RTOS partner for all ARM microcontroller cores

IAR Partner

Microchip Premier RTOS Partner

RTOS partner of NXP for all NXP ARM microcontrollers

STMicro RTOS partner supporting ARM7, ARM Cortex-M3, ARM Cortex-M4 and ARM Cortex-M0

Texas Instruments MCU Developer Network RTOS partner for ARM and MSP430 microcontrollers

OpenRTOS and SafeRTOS