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

Timer, GPIOTE, PPI problem

I'm using an nrf52832 development board and am trying to implement a simple toggling of an output pin using a timer and PPI.
Below is the code I’m using; however, the pin doesn’t toggle but stays high. Any help appreciated.

#define PIN 30

NRF_TIMER1->MODE = 0;  //timer mode

NRF_TIMER1->BITMODE = 0;  //16 bit timer width

NRF_TIMER1->PRESCALER = 4;  //16MHz / 2^4 = 1MHz

NRF_TIMER1->SHORTS = 1;  //timer cleared at CC[0]

NRF_TIMER1->CC[0] = 1000;  //.001 secs

NRF_GPIOTE->CONFIG[0] = (3 | PIN << 8 | 3 << 16 | 1 << 20);  //task mode, PIN selected, toggle, PIN high initially

//Configure PPI channel 0 to toggle PIN on every Timer 1 COMPARE[0] match

NRF_PPI->CH[0].EEP = (uint32_t)&NRF_TIMER1->EVENTS_COMPARE[0];

NRF_PPI->CH[0].TEP = (uint32_t)&NRF_GPIOTE->TASKS_OUT[0];

NRF_PPI->CHENSET = 1;  //enable PPI channel 0

NRF_TIMER1->TASKS_START = 1;

Parents Reply Children
No Data
Related