This post is older than 2 years and might not be relevant anymore
More Info: Consider searching for newer posts

Can't Get an Interrupt to Execute

Gentlemen:

I'm new to Nordic processors, but I have implemented projects with Silabs Gecko and ATTiny processors in the past.  I'm working on a project for a consumer product with an Arduino Nano 33 BLE that uses the Nordic RNF52840 processor (I picked this board because of its tiny footprint and unique peripherals).  Arduino, as yet, still hasn't offered their own software tools for timers and interrupts, so I'm largely using Nordic code.

I'm having a terrible time getting a simple hardware interrupt to work.  It's as if the interrupts are not properly enabled or something.  Here is my basic code.  I am using simple hex to set registers to be more understandable than the long variable names.  I'm a mechanical engineer by trade, so please excuse my poor coding technique.

Fullscreen
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
#include <nrf.h>
#include "nrf_timer.h"
#include "nrf_gpio.h"
const int epin = 2;
int LED = LED_BUILTIN;
uint32_t last_ecount = 0;
void setup() {
nrf_gpio_cfg_output(LED); //set built-in LED pin as output
nrf_gpio_cfg_input(epin, NRF_GPIO_PIN_PULLUP); //set pin 2 as pullup input
NVIC_EnableIRQ(GPIOTE_IRQn); //enable interrupts
NRF_GPIOTE->CONFIG[0] = 0x00010201; //low-to-high, pin2, event mode
NRF_GPIOTE->INTENSET = 0x00000001; //enable IN[0]
NRF_TIMER1->TASKS_STOP = 1;
NRF_TIMER1->MODE = 0;
NRF_TIMER1->BITMODE = 3; //timer1 32-bit mode
NRF_TIMER1->PRESCALER = 0; //use full system clock for timer1: 16 MHz
XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX

Pin2 gets a square wave and the object is to measure the period of the wave (which is then Bluetoothed to another processor). I have troubleshooted the input and know that I'm getting a signal on GPIO2 (I can light an LED using that input pin number).  But when I run the code I get no interrupt at all, ever.  I don't even get an interrupt flag NRF_GPIOTE->EVENTS_IN[0].

I feel like I've tried everything and I'm at wits end.  I'm hoping that there is something simple and stupid I'm doing/not doing. 

Does anyone see my error?  Thanks for your help.

Don

DG Devices