This post is older than 2 years and might not be relevant anymore
More Info: Consider searching for newer posts

FreeRTOS Task Priority VS Interrupt Priority nRF52840

Hi guys,

I have a 4 thread freeRTOS setup.

  1. BLE - priority 4
  2. TWI - priority 3
  3. LED - priority 2
  4. Logging - priority 1

After running for some time my code always gets caught in an infinite loop inside the vListInsert function of freeRTOS, or hardfaults @ PC:0x20003188 PSR: 0x4000000e (PendSV). It occurs like a random race-condition. Typically this indicates an issue with interrupt priorities. Looking thru my Stack trace, On the BLE thread (4), I get a SAADC IRQ (IRQ priority 6 in sdk_config.h) which triggers a callback function to write the value to the Log Thread (1). Here I try and grab a Semaphore which calls the following sequence, xSemaphoreTake() -> xQueueGenericReceive() -> vTaskPlaceOnEventList() -> vListInsert().

As an FYI I'm trying to Port FreeRTOS to the nRF52840 which i realize doesn't have an official support from Nordic yet.  Just want to double check there is nothing unique about the any vector implementation that might propagate to different behaviour in upper levels of an RTOS.  Thanks for your help.

Parents
  • Keep in mind that if a LOWER priority thread has acquired a resource, it can block a HIGHER priority thread because it cannot release the resource until the higher priority thread gives up. Since you are running the SAADC task when the hang occurs, you need to check your lower priority tasks to see if there is some place where you acquire the same mutex. There's only one lower priority task, and that's the LED one. Check there.

Reply
  • Keep in mind that if a LOWER priority thread has acquired a resource, it can block a HIGHER priority thread because it cannot release the resource until the higher priority thread gives up. Since you are running the SAADC task when the hang occurs, you need to check your lower priority tasks to see if there is some place where you acquire the same mutex. There's only one lower priority task, and that's the LED one. Check there.

Children
Related