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

How do I use PPI channel groups?

My question is regarding the PPI channel groups. The documentation is extremely limited and leaves many questions.

My goal is to generate 3 PWM signals from a timer with no IRQ handler. I have 3 PPI channels setup to a GPIOTE toggle task from a timer CC event. I also want to execute these 3 GPIOTE tasks when a 4 CC event triggers.

Here is my code that isn't working:

static void ppi_init(void) { /* Configure PPI channel 0 to toggle LED_0 on every TIMER2 COMPARE[0] match */ NRF_PPI->CH[0].EEP = (uint32_t)&NRF_TIMER2->EVENTS_COMPARE[0]; NRF_PPI->CH[0].TEP = (uint32_t)&NRF_GPIOTE->TASKS_OUT[0];

/* Configure PPI channel 1 to toggle LED_1 on every TIMER2 COMPARE[1] match */ NRF_PPI->CH[1].EEP = (uint32_t)&NRF_TIMER2->EVENTS_COMPARE[1]; NRF_PPI->CH[1].TEP = (uint32_t)&NRF_GPIOTE->TASKS_OUT[1];

/* Configure PPI channel 2 to toggle LED_2 on every TIMER2 COMPARE[2] match */ NRF_PPI->CH[2].EEP = (uint32_t)&NRF_TIMER2->EVENTS_COMPARE[2]; NRF_PPI->CH[2].TEP = (uint32_t)&NRF_GPIOTE->TASKS_OUT[2];

/* Configure PPI channel group 0 to toggle all pwm outputs on every TIMER2 COMPARE[3] match */ NRF_PPI->CHG[0] = PPI_CHG_CH0_Included<<PPI_CHG_CH0_Pos| PPI_CHG_CH1_Included<<PPI_CHG_CH1_Pos| PPI_CHG_CH2_Included<<PPI_CHG_CH2_Pos;

NRF_PPI->TASKS_CHG[0].EN=1;

/* Configure PPI channel 3 to toggle LED_0, LED_1, LED_2 on every TIMER2 COMPARE[3] match */ NRF_PPI->CH[3].EEP = (uint32_t)&NRF_TIMER2->EVENTS_COMPARE[3]; NRF_PPI->CH[3].TEP = (uint32_t)&(NRF_PPI->TASKS_CHG[0]);

/* Enable only PPI channels 0 and 1 */ NRF_PPI->CHEN = (PPI_CHEN_CH0_Enabled << PPI_CHEN_CH0_Pos) | (PPI_CHEN_CH1_Enabled << PPI_CHEN_CH1_Pos) | (PPI_CHEN_CH1_Enabled << PPI_CHEN_CH2_Pos) | (PPI_CHEN_CH3_Enabled << PPI_CHEN_CH3_Pos)

I never see the channel group trigger.

Related