Hello,
I'm trying to create a single shot PWM pulse. So I short SEQEND0 to task_stop. I setup an interrupt on stop event.
It works and enters the IRQ handler. I tried to disable re-entering IRQ by clear the register INTENCLR but that didn't work.
It keeps looping into the IRQ handler while the PWM is already stopped. I thought entering the IRQ would automatically clear
out the interrupt flag. So I tried clear with the register INTEN and it sort of works. My counter is 2 somehow. The only sure way I can disable the
interrupt is calling NVIC to disable. Could you please show what is the right way to enable interrupt and clear our the interrupt for PWM? Thanks.
NRF_PWM0->SHORTS = PWM_SHORTS_SEQEND0_STOP_Enabled << PWM_SHORTS_SEQEND0_STOP_Pos; //NRF_PWM0->INTEN = PWM_INTEN_STOPPED_Enabled << PWM_INTEN_STOPPED_Pos; NRF_PWM0->INTENSET = PWM_INTENSET_STOPPED_Enabled << PWM_INTENSET_STOPPED_Pos; NVIC_EnableIRQ(PWM0_IRQn);
int counter = 0;
void PWM0_IRQHandler(void) {
counter++;
NRF_PWM0->INTENCLR = PWM_INTENCLR_STOPPED_Clear || PWM_INTENCLR_STOPPED_Pos;
//NRF_PWM0->INTEN = PWM_INTEN_STOPPED_Disabled << PWM_INTEN_STOPPED_Pos;
// this is weird! it got caught twice here
//NRF_PWM0->INTEN = 0;
//NVIC_DisableIRQ(PWM0_IRQn);
//it looks like INTENCLR doesn't work while INTEN sort of works.
// The best one is just to disable IRQ which is overkill.
}