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


STM32F4 Interrupt + FreeRTOS

Posted by fjullien on July 24, 2014


I know it is a recurrent topic but after I read all a could find about this, I still have a problem using interrupts in combination with FreeRTOS.

I'm using libopencm3. On my board I can run the libopencm3 USB stack in interrupt mode without problem. But, if I run a FreeRTOS task, it mess up things (I get my device always connect/disconnect). I didn't look at the root cause of this connect/disconnect problem. However I suspect the usbd_poll function (called in the USB ISR) to be preempted. My ISR is as simple as this:

void otgfsisr(void) { usbdpoll(mscdev); }

And my task (I know, there is no vTaskDelay):

static portTASK_FUNCTION(vLEDFlashTask, pvParameters) { (void) pvParameters; int i = 0;

for(;;) { // It waits for TX reg empty then send the char usartsendblocking(USART1, 'A'); gpio_toggle(GPIOG, GPIO6); } }

I did setup all the priority bits as pre-emption priority:

// Same as NVICPriorityGroupConfig( NVICPriorityGroup4 ) scbsetprioritygrouping(SCBAIRCRPRIGROUPGROUP16NOSUB);

My ISR priority is 1:

nvicsetpriority(NVICOTGFS_IRQ, 1);

I also tried to change the system handler priority for systick, svcall and pendsv (as for what I understood are priority '0' by default):


However if I remove the usartsendblocking call in the task, it works as expected. Anyone as a clue ?

Thanks in advance,


STM32F4 Interrupt + FreeRTOS

Posted by rtel on July 24, 2014

I'm afraid I don't know anything about this library, or its implementation. Are you aware that ST provide STM32Cube? ( http://www.st.com/stm32cube ) That has USB drivers and FreeRTOS included.

My ISR priority is 1:

Is your interrupt making use of FreeRTOS API functions? If so then I can't image 1 will be a correct value for this. What is configMAXSYSCALLINTERRUPT_PRIORITY set to?

I also tried to change the system handler priority for systick, svcall and pendsv (as for what I understood are priority '0' by default):

The systick and pendsv priorities will be overwritten to their correct values by FreeRTOS anyway, and the svcall priority is not used other than to kick the kernel off.


STM32F4 Interrupt + FreeRTOS

Posted by fjullien on July 24, 2014

My interrupt does not use FreeRTOS API.

AFAIR, configMAXSYSCALLINTERRUPT_PRIORITY is set to 5 (I don't have access to my code right now).

Anyway, I think I'll move to STM32CubeMX. I can't spend too much time here. I just wanted to avoid STMCube, Windows and Atollic ;)

I'll get back to this later.

Thanks for your answer anyway.


[ 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