This post is older than 2 years and might not be relevant anymore
More Info: Consider searching for newer posts
This discussion has been locked.
You can no longer post new replies to this discussion. If you have a question you can start a new discussion

RTC0 Tick + PPI

/** Configures the RTC with TICK for 8Hz
 */
static void rtc0_config(void)
{                                
    NRF_RTC0->PRESCALER = 4095;                   
    NRF_RTC0->INTENSET = RTC_INTENSET_TICK_Msk;
	NVIC_EnableIRQ(RTC0_IRQn);
}

/** Init RTC0
*/
static void RTC0_init(void)
{
	NRF_RTC0->TASKS_CLEAR		= 1;
	NRF_RTC0->TASKS_START		= 1;	
}

void RTC0_IRQHandler(void)
{
	
	if(!ledOn) {
		nrf_gpio_pin_set(LED_0);
	}
	else {
		nrf_gpio_pin_clear(LED_0);
	}
	ledOn = !ledOn;
	NRF_TIMER1->TASKS_START = 1;
	NRF_RTC0->EVENTS_TICK = 0;
	
}

/** @brief Function for initializing the PPI peripheral.
*/
static void ppi_init(void)
{
    // Configure PPI channel 0 to capture Timer 1 value into  the CC[0] register.
    // This is achieved when GPIOTE detects Low-to-High transition on pin INPUT_PIN_NUMBER.
    NRF_PPI->CH[0].EEP = (uint32_t)&NRF_GPIOTE->EVENTS_IN[0];
    NRF_PPI->CH[0].TEP = (uint32_t)&NRF_TIMER1->TASKS_CAPTURE[0];

    // Configure PPI channel 1 to capture Timer 1 value into CC[1] register.
    // This is achieved when GPIOTE detects High-to-Low transition on pin INPUT_PIN_NUMBER.
    NRF_PPI->CH[1].EEP = (uint32_t)&NRF_GPIOTE->EVENTS_IN[1];
    NRF_PPI->CH[1].TEP = (uint32_t)&NRF_TIMER1->TASKS_CAPTURE[1];
	
	NRF_PPI->CH[2].EEP = (uint32_t)&NRF_RTC0->EVENTS_TICK;
    NRF_PPI->CH[2].TEP = (uint32_t)&NRF_TIMER1->TASKS_START;

    // 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_CH2_Enabled << PPI_CHEN_CH2_Pos);
}

If I call the NRF_TIMER1->TASKS_START = 1; inside the RTC0_IRQHandler my it works well, timer1 is started and I can use it but don't start it here PPI channel 3 never start the task. The other tasks on the PPI are working ok.

What I'm doing wrong?

Related