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


Timer and Uart usage in FreeRTOS with Keil

Posted by Mehmet Ali YARIM on June 19, 2009
Im using LPC2138, FreeRTOS and Keil combination.
1) I can use the "vSerialPutString" successfuly to print text only mesages on UART0. But it doesn't support parameter (e.g. %d, %x, %s ).

--> tried to assemble the full masage with "sscanf" (in Keil lib) and then call the "vSerialPutString". Faced some difficulties.

--> than decided to use the Keil's "printf". so retraged the "putchar" and "getchar" functions in "retarget.c" to "xSerialPutChar" and "xSerialGetChar". This time text is printed successfuly but parameters such as %d, %c failed and system hangs on first print of string.

--> than I gave up insisting to use functions "xSerialPutChar" and "xSerialGetChar" funtions because it is communation with UART_ISR with the help of Queues etc after I spend much time investigating the issue, although I found a solution which is not so neat. If a delay accorind to baudrate is added in the "xSerialPutChar" it is working fine.

--> than I retarget the "putchar" and "getchar" functions in "retarget.c" to
Keil's own implementation of them. So putchar waits TX buff to be empty and sends the new char. This time it is working nice, can print pramaters embedded within text. But calling "printf" from multiple tasks fails, so I protected printf with binay semaphore.

Anybode faced such issues, any comments ?

2) What system resources FreeRTOS uses? Can anyone please list it ?
Becase I want to use timer and notices that systemtick is using timer0 module (in "port.c"). on API it is suggested to use now I am considering to use "vTaskDelayUntil" and "vTaskDelay" system function of FreeRTOS. for exact timing "vTaskDelayUntil" is recommended I think ?

I could not managed to implement my own tick rates on timer1 ISR, I though I am sure about initialization steps and ISR implementations. Any idea ?

any comment on using "printf" in ISR considering the binary semaphore guarding and xportYIELD/ xportYIELDfromISR usage ?

all the best

RE: Timer and Uart usage in FreeRTOS with Kei

Posted by Richard on June 19, 2009
The xSerialPutChar() function is intended to demonstrate using queues to communicate between tasks and interrupts and to test the port. It is not intended to be an efficient example of a UART driver, especially on the LPC parts. A much more efficient and practical method would be to turn on all the UART FIFOs/Buffers/DMA [whatever is available] and use those to feed the peripheral with characters. The UART should only then generate interrupts when transmission has ended, or a buffer is full - rather than on every character. Ideally drivers would not poll UART registers, but be completely event driven.

You have to be careful with using printf() etc because some implementations can use massive stacks, and hence cause problems. You can use the stack checking features of FreeRTOS to trap these. I normally use the cut down and very stack light printf-stdarg.c implementation (search for it in the FreeRTOS download) for its sprintf() functionality, which admittedly is somewhat limited but can be extended. I don't use other functions defined in the same file however as at least one contains a bug that I am aware of.


[ 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