Quality RTOS & Embedded Software

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




Loading

Usage of xTaskNotify/xTaskNotifyWait.

Posted by andy-pevy on March 29, 2017

Hi, I am using xTaskNotify and xTaskNotifyWait to signal interrupt status between an int handler and the supporting task.

Very occasionally I am loosing indications and I'd just like to clarify my understanding of how the pair work together.

I receive data and therefore interrupts asynchronously and it is possible that I am still procesing a previous message and I get another indication informing me of new data being received.

So, my question is that if a new indication arrives while I am 'Busy', when I enter the xTaskNotifyWait routine, will it return immediately because of the existing indication, or will it wait until the next indication arrives thus ignoring the one that it already has ?.

Thanks, Andy Pevy


Usage of xTaskNotify/xTaskNotifyWait.

Posted by rtel on March 29, 2017

If you call a function to wait for a notification, but a notification is already pending, then you won't wait at all, but just return immediately.

xTaskNotify() is not an ISR safe function - is this just an error in your post, or are you actually using that function in an ISR?

Also, if you are using notifications from an interrupt, be sure to use them in their 'counting' form, rather than binary form. See the chapter on task notifications in the following book for more information: http://www.freertos.org/Documentation/RTOS_book.html


Usage of xTaskNotify/xTaskNotifyWait.

Posted by andy-pevy on March 30, 2017

Hi, I am using the HAL callback code so the interrupt domain appears to be lost, so I am really using xTaskNotify.

I am however passing 2 bits of information in the notification, I.E. Which H/W interrupt has triggered the event and an ID of a buffer that is currently being processed. If I have to use the counting notification I loose the ability to do this.

It looks like I am going to have to use a normal quere mechanism to achieve what I need.

Unless there is another way...

Andy


Usage of xTaskNotify/xTaskNotifyWait.

Posted by rtel on March 30, 2017

Hi, I am using the HAL callback code so the interrupt domain appears to be lost, so I am really using xTaskNotify.

Are you 100% sure the callback is not being called by an interrupt? Do you have configASSERT() defined? http://www.freertos.org/a00110.html#configASSERT

I am however passing 2 bits of information in the notification, I.E. Which H/W interrupt has triggered the event and an ID of a buffer that is currently being processed. If I have to use the counting notification I loose the ability to do this.

It looks like I am going to have to use a normal quere mechanism to achieve what I need.

Unless there is another way...

We often use a thread safe circular buffer to 'push' information about an interrupt into a buffer, then use the task notification to wake a task...which then reads the information from the buffer. This will become part of the FreeRTOS feature set as soon as we get time to tidy it up and fully test it - but you could rig up something similar easily enough.


[ 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