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

stop a timer through a PPI task

Hello,

 am using the NRF52-DK softdevice 6.0.0 and NRF SDK 15.0.

I am working with PPI, GPIOTE and 2 timers (called timer1 and timer2) on nrf52832

Through the COMPARE[0] event of a timer2 , I would like to stop the timer1 then Through the COMPARE[1] event of a timer2 , I would like to restart the timer1 with the use of the PPI.

Below my code for the stop parts only:

// Allocate the PPI channel err_code = nrfx_ppi_channel_alloc(&ppi_channel2); APP_ERROR_CHECK(err_code); // Assigning task and event endpoints so that the PPI channel will shut down timer1 on timer2 COMPARE[0] match. err_code = nrfx_ppi_channel_assign(ppi_channel2, nrfx_timer_event_address_get(&timer2, NRF_TIMER_EVENT_COMPARE0), ????); APP_ERROR_CHECK(err_code); // Enable the PPI channel err_code = nrfx_ppi_channel_enable(ppi_channel2); APP_ERROR_CHECK(err_code);
I do not know can I achieve that and what I have to write instead of the ????

Thanks for your help.

Parents
  • Hi Omnia,

    You should try the following way:

    // Assigning task and event endpoints so that the PPI channel will shut down timer1 on timer2 COMPARE[0] match.
        err_code = nrfx_ppi_channel_assign(ppi_channel2,
                                              nrfx_timer_event_address_get(&timer2, NRF_TIMER_EVENT_COMPARE0),
                                              nrf_drv_timer_task_address_get(&timer1, NRF_TIMER_TASK_STOP));
        APP_ERROR_CHECK(err_code);

    Don't forget to declare the timer1 instance.

    Kind regards,
    Sylvain

  • Hi Sylvain,

    I thought having tried this method at the first read but it appears I made a too quick shortcut between the new nrfX API and the previous nrf one.

    Indeed : nrfx_timer_task_address_get is the new nrf_drv_timer_task_address_get method

    BUT nrf_timer_task_address_get does not seems to be equivalent to nrfx_timer_task_address_get.

    My fault, Thanks to you for pointing out my mistake.

Reply
  • Hi Sylvain,

    I thought having tried this method at the first read but it appears I made a too quick shortcut between the new nrfX API and the previous nrf one.

    Indeed : nrfx_timer_task_address_get is the new nrf_drv_timer_task_address_get method

    BUT nrf_timer_task_address_get does not seems to be equivalent to nrfx_timer_task_address_get.

    My fault, Thanks to you for pointing out my mistake.

Children
No Data
Related