Quality RTOS & Embedded Software

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


Loading

High Frequency Interrupt and Queues/Semaphores

Posted by imaduck on July 8, 2017

Hi everyone,

I have a question regarding FreeRTOS with high Frequency Interrupts and Queues/Semaphores. The setup: Cortex M4 (NXP LPC4337) UART Interrupt with high data rates One Semaphore as new data notify Given by the UART ISR with: ~~~ configASSERT(uart3NewDataSemaphore); xSemaphoreGiveFromISR(uart3NewDataSemaphore, &higherPriorityTaskWokenUart3); portENDSWITCHINGISR(higherPriorityTaskWokenUart3); ~~~

The counterpart tries to take this semaphore wit:

~~~ xSemaphoreTake(uart3NewDataSemaphore, portMAX_DELAY); ~~~

With no or small data rate (e.g. with manual serial input through putty) everything works fine. But if we connect a peripheral with a lot of data we get in trouble and often the programm hangs up in the function vListInsert in FreeRTOS/list.c.

The following IRQs are activated: CAN1 with priority 6 ADC0 with priority 6 UART3 with priority 6 configPRIOBITS is set to __NVICPRIO_BITS which equals 3

Maybe someone here as an idea about the problem?

Cheers, Marvin

Edit: Updated IRQ Priorities


High Frequency Interrupt and Queues/Semaphores

Posted by richarddamon on July 8, 2017

That sort of hang up is most often caused by the priorities being higher (lower in value for Arms) than configMAXSYSCALLINTERRUPT_PRIORITY which will cause corruption of FreeRTOS control variables. High interrupt rates will make it more likely that this will cause an issue.

A second point is that when you have a high interrupt rate, you generally want to do the preliminary processing inside the ISR, and have it buffer up a packet of data and then pass that down to a task to process as a packet (if you can't setup a DMA transfer to handle the high speed collection). Task switching does cost time, so doing it too fast can exhaust you CPU processing. (It sort of depends on how fast is 'fast' and how fast is the processor.

A smaller point is that if you do need to transfer to a task, if you can use the direct-to-task notification you will save some processing.

One last comment on your architecture, is that you are using a semaphore on data ready and the task does the actual data read, you are requiring that the task actually gets the read done within a character time or your might lose data (depending on the fifo abilities of the Serial Port). This is one reason it is also good to get the data in the ISR.


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


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

Latest News

NXP tweet showing LPC5500 (ARMv8-M Cortex-M33) running FreeRTOS.

Meet Richard Barry and learn about running FreeRTOS on RISC-V at FOSDEM 2019

Version 10.1.1 of the FreeRTOS kernel is available for immediate download. MIT licensed.

View a recording of the "OTA Update Security and Reliability" webinar, presented by TI and AWS.


Careers

FreeRTOS and other embedded software careers at AWS.



FreeRTOS Partners

ARM Connected RTOS partner for all ARM microcontroller cores

Espressif ESP32

IAR Partner

Microchip Premier RTOS Partner

RTOS partner of NXP for all NXP ARM microcontrollers

Renesas

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

Xilinx Microblaze and Zynq partner