Hi,
I'm working on a tone library. I'm using timer2 and ppi channels to generate 50% pwm signal. It's working fine.
Now i want to add another timer comparison ( timeout of my tone ).
So in my timer init function, i add compare1 flag in INTENSET Register :
PWM_TIMER->INTENSET = TIMER_INTENSET_COMPARE0_Msk | TIMER_INTENSET_COMPARE1_Msk;
Then in my IrQ Handler i put additional code for this comparison
void PWM_IRQHandler(void)
{
// PWM Comparator
if ((PWM_TIMER->EVENTS_COMPARE[0] != 0) &&
((PWM_TIMER->INTENSET & TIMER_INTENSET_COMPARE0_Msk) != 0))
{
// Sets the next CC1 value
PWM_TIMER->EVENTS_COMPARE[0] = 0;
PWM_TIMER->CC[0] = PWM_TIMER->CC[0] + pwm_nbr_ticks ;
}
if ((PWM_TIMER->EVENTS_COMPARE[1] != 0) &&
((PWM_TIMER->INTENSET & TIMER_INTENSET_COMPARE1_Msk) != 0))
{
PWM_TIMER->TASKS_STOP = 1;
}
}
In my main
// initialisation comparateurs
PWM_TIMER->CC[0] = pwm_nbr_ticks;
PWM_TIMER->CC[1] = delay_nbr_ticks;
// reset timer
PWM_TIMER->TASKS_CLEAR = 1;
// lancement du timer
PWM_TIMER->TASKS_START = 1;
The 2 comparisons are not working, i don't understand wy i can't add a comparison..... It's working well with just cc[0] comparison.