Hello ,
I am working on the development kit nrf52, i want to know how i canget the value of the RTC overflw and then how i can reset the RTC to zero.
thank you in advance
Best regards
Hello ,
I am working on the development kit nrf52, i want to know how i canget the value of the RTC overflw and then how i can reset the RTC to zero.
thank you in advance
Best regards
You cannot get the overflow value but you can get an overflow event in EVENTS_OVERFLW register. For this you have to enable this event in RTC->EVTEN register.
You then need to enable interrupt for this in the INTENSET and increment a static variable everytime you get the overflow event. After incrementing the variable, you clear the overflow event.
for example in the RTC interrupt handler you can do something like this
static uint8_t tick_overflow_count = 0; /* check for overflow in RTC counter */ if(nrf_rtc_event_pending(portNRF_RTC_REG, NRF_RTC_EVENT_OVERFLOW)) { nrf_rtc_event_clear(portNRF_RTC_REG, NRF_RTC_EVENT_OVERFLOW); tick_overflow_count++; } // then you get the full value uint32_t systick_counter = nrf_rtc_counter_get(portNRF_RTC_REG); full_value = ((tick_overflow_count << portNRF_RTC_BITWIDTH) + systick_counter);
Hello Aryan ,
Thank you for respond.
I want to reset the rtc by a extern interruption (accelerometer), i want to know which function can i use?
Thank you in advance.
This will reset the RTC counter to zero everytime you have any interrupt from accelerometer.
To know more about how to configure GPIOTE and PPI for this, you need to look at their SDK examples in SDK\examples\peripheral and read the docs about them.
Thank ou Mr Aryan
there are any possibility to activate the sleep mode by an rtc overflow event?
The only way you can do it is in the RTC ISR_handler. There is no shortcut in hardware to do this automatically.