I am trying to use the EVENTS_PWMPERIODEND interrupt to read a GPIO pin on every falling edge of an output GPIO that is driven from the PWM module.
The description in the reference manual is: EVENTS_PWMPERIODEND 0x118 Emitted at the end of each PWM period
...So I expected that this event could provide that interrupt for me.
I am setting up the PWM to generate five pulses, like this:
data.pwm0_duty[0] = 8;
data.pwm0_duty[1] = 8;
data.pwm0_duty[2] = 8;
data.pwm0_duty[3] = 8;
data.pwm0_duty[4] = 8;
NRF_PWM0->MODE = (PWM_MODE_UPDOWN_Up << PWM_MODE_UPDOWN_Pos);
NRF_PWM0->PRESCALER = (PWM_PRESCALER_PRESCALER_DIV_1 << PWM_PRESCALER_PRESCALER_Pos);
NRF_PWM0->COUNTERTOP = (32 << PWM_COUNTERTOP_COUNTERTOP_Pos);
NRF_PWM0->SEQ[0].PTR = ((uint32_t)swd_data.pwm0_duty << PWM_SEQ_PTR_PTR_Pos);
NRF_PWM0->SEQ[0].CNT = 5;
NRF_PWM0->SEQ[0].REFRESH = 0;
NRF_PWM0->SEQ[0].ENDDELAY = 0;
NRF_PWM0->PSEL.OUT[0] = (CLK_PIN_NUMBER << PWM_PSEL_OUT_PIN_Pos)
| (PWM_PSEL_OUT_CONNECT_Connected << PWM_PSEL_OUT_CONNECT_Pos);
NRF_PWM0->ENABLE = (PWM_ENABLE_ENABLE_Enabled << PWM_ENABLE_ENABLE_Pos);
NRF_PWM0->SEQ[0].PTR = ((uint32_t)data.pwm0_duty << PWM_SEQ_PTR_PTR_Pos);
NRF_PWM0->SEQ[0].CNT = 4;
NRF_PWM0->DECODER = (PWM_DECODER_LOAD_Common << PWM_DECODER_LOAD_Pos)
| (PWM_DECODER_MODE_RefreshCount << PWM_DECODER_MODE_Pos);
NRF_PWM0->INTENSET = (PWM_INTENSET_SEQEND0_Enabled << PWM_INTENSET_SEQEND0_Pos)
| (PWM_INTEN_PWMPERIODEND_Enabled << PWM_INTEN_PWMPERIODEND_Pos);
NRF_PWM0->TASKS_SEQSTART[0] = 1;
...However, the PWMPERIODEND interrupt only seems to be firing once.
Am I doing something wrong, or have I interpreted the behavior of this event wrong?
Thanks.
--ken