Quality RTOS & Embedded Software

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




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) 2004-2010 Richard Barry. Copyright (C) 2010-2016 Real Time Engineers Ltd.
Any and all data, files, source code, html content and documentation included in the FreeRTOSTM distribution or available on this site are the exclusive property of Real Time Engineers Ltd.. See the files license.txt (included in the distribution) and this copyright notice for more information. FreeRTOSTM and FreeRTOS.orgTM are trade marks of Real Time Engineers Ltd.

Latest News:

FreeRTOS V9.0.0 is now available for download.


Free TCP/IP and file system demos for the RTOS


Sponsored Links

⇓ Now With No Code Size Limit! ⇓
⇑ Free Download Without Registering ⇑


FreeRTOS Partners

ARM Connected RTOS partner for all ARM microcontroller cores

Renesas Electronics Gold Alliance RTOS Partner.jpg

Microchip Premier RTOS Partner

RTOS partner of NXP for all NXP ARM microcontrollers

Atmel RTOS partner supporting ARM Cortex-M3 and AVR32 microcontrollers

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

Xilinx Microblaze and Zynq partner

Silicon Labs low power RTOS partner

Altera RTOS partner for Nios II and Cortex-A9 SoC

Freescale Alliance RTOS Member supporting ARM and ColdFire microcontrollers

Infineon ARM Cortex-M microcontrollers

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

Cypress RTOS partner supporting ARM Cortex-M3

Fujitsu RTOS partner supporting ARM Cortex-M3 and FM3

Microsemi (previously Actel) RTOS partner supporting ARM Cortex-M3

Atollic Partner

IAR Partner

Keil ARM Partner

Embedded Artists