janakas wrote on Wednesday, November 01, 2006:
Hello everyone,
I am currently running FreeRTOS on a Atmel AT91SAM7S256.
We use FreeRTOS Queues and Semaphores for inter-thread communications as well as ISR communications.
The problem I am having is, during heavy application loading, I miss TWI interrupts; hence overflows. Further investigations point at xQueueReceive, xQueueSend causing this. My hypothesis is that because queue activity (hence semaphore activity) causes the interrupts to be disabled for 240us, this causes it to miss the TWI RxRdy interrupt; eventually causing the overflow of the hardware.
The Oscilloscope trace of the TWI overflow and associated signals has been captured and is viewable here:
http://www.flickr.com/photo_zoom.gne?id=285266143&size=o
To capture this, I toggled IO lines on different events.
The signal descriptions are as follows (listed down the right hand edge in the image):
Label Signal name
---------------------------------------------------------------------------------------------------------------------------------
A2 TWI Clock
A1 TWI Data
7 Idle Activity task (Every time around the loop)
6 EnterCritical - Exit Critical timings (Note that I am forcing this pin low at portRESTORE_CONTEXT)
5 USB interrupt time (Logic 1 at start of USB interrupt, 0 at end of interrupt)
4 TWI comms Interrupt (Logic 1 at start of TWI interrupt, 0 at end of interrupt)
3 NA
2 QueueRecive activity (xQueueReceive but clearing this before any possible context switching)
1 QueueSend activity (xQueueSend but clearing this before any possible context switching)
0 RTOS Interrupt ( vTaskIncrementTick, vTaskSwitchContext )
As you can seen the periodic TWI_RxRdy interrupt occurs approx every 200us and CANNOT be invoked while queues are being manipulated. Hence the next TWI interrupt after Interrupts are re-enabled is for the TWI overflow.
===============
Questions:
1. Is it possible to ONLY disable the PIT timer interrupt while queues are being manipulated & context switching ?
2. Is there any variations of the queue implementation (even commercial ones) , that do not disable the interrupts, that I could use in FreeRTOS ?
3. Is there any other solutions to this problem ?
===============
Misc information.
The application that uses the following:
- USB (HID class, custom pipes and custom host app)
- TWI
- Serial Comms
- DBGU Comms
- SPI
- Timer Interrupt
+ 5 threads at different priority levels (including idle priority)