Quality RTOS & Embedded Software

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


Loading

Defer task from a fast interrupt (100kHz)

Posted by mineiro on January 30, 2019

Hello,

I'm new to FreeRTOS and I'm not sure which architectural approach with FreeRTOS I should use. My task is the following: I'm using an Infineon XMC4100 Cortex M4 with 80 MHz. I'm having a fast interrupt with 100 kHz triggered from a PWM. I would like to scale data and calculate 2 current controllers with 100 kHz. I would like to calculate some other controllers with 5 kHz. And I'm having slower communication tasks running in the backround.

I tried do defer the 100kHz interrupt in a task using TaskNotifier. I measured the delay that causes the defering with digital IOs and a scope. It's 4.5µs without any calculations which is too much if you have only 10µs in total.

So the question is how to do this better? I could calculate the data scaling and current controllers directly in the interrupt, but that would need quite some calculation time and it is always recommended in the FreeRTOS docu to keep the interrupt short. So what would be the disadvantage of spending let's say 50% of the time in an interrupt blocking the task scheduler? And what would be the best way to trigger a 5 kHz task? Or should I resign using FreeRTOS, but then the communication tasks would be more difficult to program. If I'm not having enough calculation time at all I could run the controllers with 50KHz instead of 100 kHz, but the problem is still similar. Any hints?

Greetings, Tobias


Defer task from a fast interrupt (100kHz)

Posted by richarddamon on January 30, 2019

10us period and 80 MHz processor says you have only 800 cycles per interrupt. You CAN'T have a 'lengthy' calculation that you need to do each cycle, as you don't have much time there at all.

I definitely would NOT defer that calculation from that interrupt as, as you noted, the overhead will be significant. You might have that ISR do a divide by 20 and defer, or setup another timer to run at 5kHz and have that trigger the lower speed calculation. This would also allow the 100kHz to not use any FreeRTOS API and thus be allowed to be high enogh priority that critical sections won't block it, reducing the jitter on the interrupt.


Defer task from a fast interrupt (100kHz)

Posted by mineiro on January 30, 2019

I know I'm sort of short on calculation time, but as I said, probably I can also calculate the controllers with 50kHz which would give me 1600 cycles. But the problem with defering the interrupt would be the same, so thanks for your advice!


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


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

Latest News

FreeRTOS v10.2.0 is available for immediate download. MIT licensed, and including RISC-V and ARMv8-M (Cortex-M33) demos.

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

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

Cadence Tensilica Cortes

Espressif ESP32

IAR Partner

Microchip Premier RTOS Partner

RTOS partner of NXP for all NXP ARM microcontrollers

Mediatek

Renesas

RISC-V

SiFIve RISC-V

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