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

Waking a task after reading a buffer of data

Posted by Nobody/Anonymous on December 27, 2005
Hi all,

I need to read/write data from/to device (SPI) in buffered mode.
I have a user task T calling a 'read' function to get data from SPI through the ISR routine.
I was inspired from 'serial.c' example and so I put dataIN and dataOUT queue.
In the dataIN queue the ISR routine puts new data coming from device (with xQueueSendFromISR), meanwhile the user task T are waiting for them (with xQueueReceive).
How can I wake the task T immediatly after the end of the ISR routine?

I don't understand the usage of the parameter xTaskWokenByPost (the last parameter) of xQueueSendFromISR, if I have a user task waiting for data on a queue, is it possible to make it wait for N queue elements?

RE: Waking a task after reading a buffer of data

Posted by Nobody/Anonymous on December 27, 2005
If you followed the serial example then xTaskWokenByPost will get automatically set to true if the received data caused a task to unblock - provided the task that unblocked has a higher priority than the task that was interrupted.

If at the end of your ISR you find xTaskWokenByPost is true you can call the context switch function (how this is done depends on your port, but just copy the serial example again). When you call the context switch function the ISR will return to the unblocked task, rather than the task that was interrupted. This is what you want because it is now the highest priority task that is able to execute.

If you want the unblocked task to execute when N data elements are available then you have some choices:

1) Don't block the task on the queue, but instead suspend the task, then when N data bytes are available unsuspend the task from within the ISR. The ISR will need to keep a count of how many data items are available.

2) Instead of queueing individual data items, queue a structure that contains N data items. This way the ISR will only post onto the queue (and wake the task) when all N items are available.

3) Some combination of the above.

Basically it sounds like you want a bit more intelligence in your ISR so it can control your tasks more efficiently.

RE: Waking a task after reading a buffer of d

Posted by Nobody/Anonymous on January 3, 2006
Thank u very much for your advices.

I'm going to try...


[ 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