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

RTC Clear task problem

I'm trying to setup the RTC in the nRF52 to count with a resolution of 1mS. As the count has only a 24 bit value, I wish to clear the count every hour to start again.

There doesn't seem to be a SHORTS register in the RTC which I would expect to be able execute the clear task on a COMPARE event.

I've tried using the PPI, but the count does not get cleared:

uint32 compare0Event = nrf_rtc_event_address_get( rtc, NRF_RTC_EVENT_COMPARE_0 );
uint32 clearTask = nrf_rtc_task_address_get( rtc, NRF_RTC_TASK_CLEAR );
nrf_ppi_channel_endpoint_setup( NRF_PPI_CHANNEL0, compare0Event, clearTask );
nrf_ppi_channel_enable( NRF_PPI_CHANNEL0 );

So I'm trying to manually clear the count every hour (COMPARE0 event):

nrf_rtc_task_trigger( rtc, NRF_RTC_TASK_CLEAR );

But when I do, my compare event each second (COMPARE1 event) just stops.

This seems like it should be the easiest thing in the world but has caused all sorts of problems!

Related