My application is built using the nRF52832 device.
The system must only be "active" between certain times (5am through to 9pm).
I am a newbie and have no idea how to set the RTC of the nRF52832.
I could either set the time in a text string OR set the time of the PC in the nRF52832 when the program is uploaded.
I use the following code snipped to check if the time is within 5am and 9pm:
if(current_time.hours > 4 && current_time.hours <10)
I need to be able to set the following:
For keeping track of time on the nRF52, I would recommend taking a look at the nrf-calendar-example we have on Github.
Declan gravatar image
1 ●1 ●3
answered 18 mins ago
Thanks, but sorry - "nrf-calendar-example" makes no sense to me. I am very new to the whole Nordic / Keil environment. I desperately need assistance in being able to set the time and read(get) the time as per above. Any help would be greatly appreciated.
Well, I think what Sigurd was trying to say in not so many words is that the RTC peripheral you see on the nRF52 is a real time counter, not a real time clock/calendar. You can use it to keep track of ticks at almost any interval you want, but you have to build the logic on top of it if you want to use it as a clock/calendar. The example he is pointing you to is a way to do that.
Thanks, it's building the logic that I do not understand. I must keep track of the hours in a day.
How can I set the current PC time into:
void date_time_set_timestamp(uint32_t timestamp)
RTC2_counter = NRF_RTC2->COUNTER;
if(timestamp < (RTC2_counter / 8))
date_time_clock_timestamp = 0;
date_time_clock_timestamp = timestamp - (RTC2_counter / 8);