Hi there,
I'm working on something with hard real-time requirements - for this and a number of other reasons, I'm writing directly to the registers.
I'm trying to generate an interrupt when pressing SW1 on the nRF52840-DONGLE board (connect to P1.06), however, I can't get it to fire. Code is below:
void GPIOTE_IRQHandler()
{
int i = 1;
}
void setup_button()
{
const uint32_t CHAN = 3;
NRF_P1->PIN_CNF[6] = ((uint32_t)GPIO_PIN_CNF_DIR_Input << GPIO_PIN_CNF_DIR_Pos)
| ((uint32_t)GPIO_PIN_CNF_INPUT_Connect << GPIO_PIN_CNF_INPUT_Pos)
| ((uint32_t)GPIO_PIN_CNF_PULL_Pullup << GPIO_PIN_CNF_PULL_Pos)
| ((uint32_t)GPIO_PIN_CNF_DRIVE_S0S1 << GPIO_PIN_CNF_DRIVE_Pos)
| ((uint32_t)NRF_GPIO_PIN_NOSENSE << GPIO_PIN_CNF_SENSE_Pos);
NRF_GPIOTE->CONFIG[CHAN] =
GPIOTE_CONFIG_MODE_Event << GPIOTE_CONFIG_MODE_Pos |
GPIOTE_CONFIG_POLARITY_Toggle << GPIOTE_CONFIG_POLARITY_Pos |
NRF_GPIO_PIN_MAP(1, 6) << GPIOTE_CONFIG_PSEL_Pos;
NRF_GPIOTE->INTENSET |= 0x01UL<<CHAN;
}
int main(void)
{
setup_button();
while (true)
{
__WFI();
int i = 1;
}
}
I've run the above code and put a breakpoint on both lines 3 or 32; neither get hit when pressing the button. I've set it as a debug build; looking at the assembly, the "int i = 1" instructions are definitely compiled. I've also tried removing the __WFI() from the main loop and let it run flat out - no difference.
Clearly I'm missing something, but from the doco it's not clear what it is. Any guidance is appreciate. Thanks!