portEND_SWITCHING_ISR delay

jdurand wrote on Saturday, August 25, 2012:

V7.2.0, LPC1754 using LPCXpresso

I’m building an application that currently has 4 tasks running
idle with hook, priority 0
two tasks with vTaskDelay in them, priority 1
Communications task with xSemaphoreTake in it, priority 4

In an interrupt at the end of a DMA I execute
xSemaphoreGiveFromISR(DMA_Done, &xHigherPriorityTaskWoken);
set bit on a port
portEND_SWITCHING_ISR(xHigherPriorityTaskWoken);

the communications task clears the bit as soon as it gets the semaphore

What I’m seeing is the communications task doesn’t run until about the next tick (I haven’t checked precisely, but it looks to be right after a tick).  I’ve traced through and xHigherPriorityTaskWoken is true, but when I step out of the interrupt I’m back in the Idle task.

jdurand wrote on Saturday, August 25, 2012:

I forgot, the Idle Hook has a _WFI() in it, if that matters.

jdurand wrote on Saturday, August 25, 2012:

More testing, it seems the semaphore is working fine, but for some reason the timer that triggers the DMA isn’t firing at the right time.  So, semaphore looks ok, something up with timer/DMA interaction.  ???

rtel wrote on Saturday, August 25, 2012:

something up with timer/DMA interaction

That would be LPC17xx specific, rather than FreeRTOS specific, so I couldn’t comment directly.  I would be surprised if there were any issues that were not mentioned in the chip’s errata though.

Regards.

jdurand wrote on Saturday, August 25, 2012:

Yes, not a FreeRTOS problem.  I keep trying to break it but you did a very good job.  :slight_smile:

In this case I have one timer with three match registers enabled.  I set the registers with the timer reset and they give it a GO.  Two of the three matches hit dead on time, the third one is almost 1mS late out of 22.9mS (over 4% error!).  SystemCoreClock tests dead on.

I may need a LOT more caffeine for this one.