Quality RTOS & Embedded Software

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


Loading

IRQs being disabled

Posted by Geoffrey McRae on July 19, 2010
I am having a problem with a STM32 and USART ISRs with the queue API. From what I understand, I should be able to fill a queue till it blocks by specifying portDELAY_MAX and having INCLUDE_vTaskDelay defined to 1.

What is occuring is it works fine for the first 5-6 or so iterations, when it then enters an infinite loop in list.c on line 150.

I read the commented warning, I have increased stack size heaps to be sure its not an overflow, and set my NVIC priority group to 4. The NVIC IRQ handler preemption priority is set to configLIBRARY_KERNEL_INTERRUPT_PRIORITY which is defined as 15.

Here is the code that I am using:
http://www.spacevs.com/usart.c

I have been desperately stuck on this problem for the last week and I am sure its a face palm type error.... If someone can please look at it and tell me where I have gone wrong it would be GREATLY appreciated.

Thanks in advance

RE: IRQs being disabled

Posted by Geoffrey McRae on July 19, 2010
Oh, and ill add that when it gets into the infinite loop, my breakpoint on the systick hook no longer fires indicating that interrupts have been left disabled....

RE: IRQs being disabled

Posted by Dave on July 19, 2010
“ortDELAY_MAX and having INCLUDE_vTaskDelay defined to 1”


portMAX_DELAY will be an indefinite block time if INCLUDE_vTaskSuspend is set to 1, not INCLUDE_vTaskDelay.

“and set my NVIC priority group to 4”


I think the examples just leave that at 0.


“Oh, and ill add that when it gets into the infinite loop, my breakpoint on the systick hook no longer fires indicating that interrupts have been left disabled....”


Not necessarily. To know if interrupts were disabled or not check the relevant status bits. If a low priority interrupt is not firing then maybe you are just looping in a higher priority interrupt.

RE: IRQs being disabled

Posted by Richard Damon on July 19, 2010
One thing that looks suspicious to me is this code in usart_read


portENTER_CRITICAL();
while(USART_GetFlagStatus(h->port, USART_FLAG_RXNE) == RESET)
return USART_ERR_NODATA;

*byte = USART_ReceiveData(h->port) & 0x7F;
portEXIT_CRITICAL();
return USART_ERR_OK;


If the condition of the while loop is true, then the function immediately exits with an error return code, leaving you in a critical section (and the while loop will NEVER repeat, because it exits with a return).

RE: IRQs being disabled

Posted by Geoffrey McRae on July 19, 2010
Sorry, yes, I ment INCLUDE_vTaskSuspend, it is defined.

Nope, the examples all set it to group_4.

Further investigation shows that portNVIC_PENDSVSET is being set, but setting a breakpoint on the IRQ handler never triggers once the application gets stuck in its loop. I think I have narrowed it down...

My application starts an init task which sets up IRQ's and then creates the other tasks, which once done, it then calls vTaskDelete(NULL). According to docs this should be safe, could this be the issue?

RE: IRQs being disabled

Posted by Geoffrey McRae on July 19, 2010
@richard_damon: That is an issue, thanks for the heads up, however the USART_MODE_IRQ flag is set in my test app with the issue, so that code is not actually running.

RE: IRQs being disabled

Posted by Geoffrey McRae on July 19, 2010
Found the problem, and yes it was a facepalm one.... had an extra taskEXIT_CRITICAL in a function that never called ENTER... caused all sorts of weirdness


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


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

Latest News

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