In SDK 11.0 it seems that in case pin 31 is configured as a button (using port events), nrf_gpiote_task_enable keeps triggering the port event due too a work around for OUTINIT PAN.
In SDK 11.0 it seems that in case pin 31 is configured as a button (using port events), nrf_gpiote_task_enable keeps triggering the port event due too a work around for OUTINIT PAN.
I'm using a NRF52 chip on a custom board with a button connected to pin 31. The button is handled through app_button (low power port event). The NRF52 generates PWM on some other pins using GPIOTE and PPI. This requires calling nrf_gpiote_task_enable and nrf_gpiote_task_disable when switching between PWM on and off. Every time nrf_gpiote_task_enable is called, a port event is generated because pin 31 is configured as a low power GPIOTE pin and nrf_gpiote_task_enable temporarily changes the pin 31 GPIOTE config.
Code from the SDK:
__STATIC_INLINE void nrf_gpiote_task_enable(uint32_t idx)
{
uint32_t final_config = NRF_GPIOTE->CONFIG[idx] | GPIOTE_CONFIG_MODE_Task;
/* Workaround for the OUTINIT PAN. When nrf_gpiote_task_config() is called a glitch happens
on the GPIO if the GPIO in question is already assigned to GPIOTE and the pin is in the
correct state in GPIOTE but not in the OUT register. */
/* Configure channel to Pin31, not connected to the pin, and configure as a tasks that will set it to proper level */
NRF_GPIOTE->CONFIG[idx] = final_config | ((31 << GPIOTE_CONFIG_PSEL_Pos) & GPIOTE_CONFIG_PSEL_Msk);
__NOP();
__NOP();
__NOP();
NRF_GPIOTE->CONFIG[idx] = final_config;
}
I'm using a NRF52 chip on a custom board with a button connected to pin 31. The button is handled through app_button (low power port event). The NRF52 generates PWM on some other pins using GPIOTE and PPI. This requires calling nrf_gpiote_task_enable and nrf_gpiote_task_disable when switching between PWM on and off. Every time nrf_gpiote_task_enable is called, a port event is generated because pin 31 is configured as a low power GPIOTE pin and nrf_gpiote_task_enable temporarily changes the pin 31 GPIOTE config.
Code from the SDK:
__STATIC_INLINE void nrf_gpiote_task_enable(uint32_t idx)
{
uint32_t final_config = NRF_GPIOTE->CONFIG[idx] | GPIOTE_CONFIG_MODE_Task;
/* Workaround for the OUTINIT PAN. When nrf_gpiote_task_config() is called a glitch happens
on the GPIO if the GPIO in question is already assigned to GPIOTE and the pin is in the
correct state in GPIOTE but not in the OUT register. */
/* Configure channel to Pin31, not connected to the pin, and configure as a tasks that will set it to proper level */
NRF_GPIOTE->CONFIG[idx] = final_config | ((31 << GPIOTE_CONFIG_PSEL_Pos) & GPIOTE_CONFIG_PSEL_Msk);
__NOP();
__NOP();
__NOP();
NRF_GPIOTE->CONFIG[idx] = final_config;
}