I'm having trouble in getting a PWM signal for LEDs running smoothly on a NXP LPC1857 running uC/OS-III. Only when I disable the OS systick running at 1ms the flickering which regulary occurs stops.
I have set up my timer with 4 match registers, one for each color (Red, Green, Blue) and one for the complete period. The first three match outputs are clearing the physical output pins for each color. The last period match generates an interrupt to set all three color outputs for the next period.
i tried to disable interrupts from the OS during the timer0 interrupt by adding the following code arround the interrupts:
void TIMER0_IRQHandler(void)
{
CPU_SR_ALLOC();
OS_CRITICAL_ENTER();
OSIntEnter();
if (Chip_TIMER_MatchPending(PWM_TIMER, PWM_RED))
{
Chip_TIMER_ClearMatch(PWM_TIMER, PWM_RED);
PWM_TIMER->EMR &= ~(((uint32_t) 0x01) << PWM_RED);
}
if (Chip_TIMER_MatchPending(PWM_TIMER, PWM_GREEN))
{
Chip_TIMER_ClearMatch(PWM_TIMER, PWM_GREEN);
PWM_TIMER->EMR &= ~(((uint32_t) 0x01) << PWM_GREEN);
}
if (Chip_TIMER_MatchPending(PWM_TIMER, PWM_BLUE))
{
Chip_TIMER_ClearMatch(PWM_TIMER, PWM_BLUE);
PWM_TIMER->EMR &= ~(((uint32_t) 0x01) << PWM_BLUE);
}
if (Chip_TIMER_MatchPending(PWM_TIMER, PWM_MATCH))
{
Chip_TIMER_ClearMatch(PWM_TIMER, PWM_MATCH);
PWM_TIMER->EMR |= (((uint32_t) 0x01) << PWM_RED);
PWM_TIMER->EMR |= (((uint32_t) 0x01) << PWM_GREEN);
PWM_TIMER->EMR |= (((uint32_t) 0x01) << PWM_BLUE);
}
OS_CRITICAL_EXIT();
OSIntExit();
}
Does anyone has an idea why the systick could cause the flickering in the PWM signal?