I have a hardware interrupt setup on PWM1 that is set at 20 KHz. The ISR posts a semaphore every second time through. A task is pending on this semaphore. The task takes 23 us to execute. When I check the timing of the ISR I see the first time through takes 2 us to execute. The next time through takes 30 us. The time from rising edge to rising edge is 50 us. This is seen by setting an output high on entry to the ISR and setting it low on exit and vioewing on the scope. It appears that one of two things is happening. Either the command to post a semaphore takes 27 us or the act of posting the semaphore is causing the task to wake up and execute within the context of the hardware interrupt. This is not what I expected. I expected the hardware to post the semaphore within a us and then exit with the task waking up after the hardware intterupt finishes. I am using the 28335 chip. Any ideas? Below is the ISR.
interrupt void MainISR(void)
{
LED_ON;
// Verifying the ISR
IsrTicker++;
if (++fs_isrCounter >= 2)
{
fs_isrCounter = 0;
SEM_post(&SEM_MCT);
}
// Enable more interrupts from this timer
EPwm1Regs.ETCLR.bit.INT = 1;
LED_OFF;
// Acknowledge interrupt to recieve more interrupts from PIE group 3
PieCtrlRegs.PIEACK.all = PIEACK_GROUP3;
}