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

nRF52 RTC Update Issue

Hi,

I'm using nrf52832 to interface RTC using nrf_calendar.c file.

I have start the RTC at 8:59:00, it will reaches 9:00:00. After that automatically it will resets and again start from 8:59:00 upto 9:00:00.

It repeats same operation.

Intialize the RTC time only once in the main().

Kindly give the solution as soon as possible.

Thanks & Regards

Senthilkumar

Parents
  • Hi 

    If I understand you correctly you have integrated the nrf_calendar.c file in a larger project?

    Could there be some other issue with the application that leads to a system assert and a reset?

    What about the watchdog, is it enabled?

    When you say that you "start the RTC at 8:59:00", how do you configure this?

    Best regards
    Torbjørn

  • Hi,

    Thanks for your reply.

    RTC configuration.

    #define CAL_RTC NRF_RTC2
    #define CAL_RTC_IRQn RTC2_IRQn
    #define CAL_RTC_IRQHandler RTC2_IRQHandler
    #define CAL_RTC_IRQ_Priority 3

    To Configure RTC time using nrf_cal_set_time(19, 10, 16, 8, 59, 00);

    Read RTC data in while loop using strftime(date_time, 9, "%X", nrf_cal_get_time());

    WDT is not used.

    But, i have two I2C devices.

    Thanks & Regards

    Senthilkumar

  • Hi

    Are you able to run the debugger and see what happens?

    If you put a breakpoint at the start of main you should be able to detect if the code resets during execution. 

    Also, if you have any error handlers in the application, see if they are called when the application is running. 

    Best regards
    Torbjørn

  • Hi,

    reset problem is solved.

    my project is based on date & time. So,need to check date & time, do some functions then device enter into sleep mode.

    Note: date and time update till the battery power down (or) Change by coding 

    which type of RTC is suitable for my project? 

    internal RTC means (App_timer based RTC or RTC1 or RTC2)?

    external RTC?

    kindly give the solution.

    Regards,

    Senthilkumar

  • Hi 

    Good to hear you figured out the reset issue Slight smile

    By internal RTC I assume you mean internal LF clock?

    Whether you are using app_timer, RTC0, RTC1 or RTC2 you have the choice of using the internal 32kHz RC oscillator, or using the external 32kHz crystal. 

    The external crystal will usually have an accuracy of 20ppm or better, which means you are looking at a worst case clock drift of 1.7 seconds pr day. 

    The internal LF oscillator is way less accurate, and can cause minutes or hours of drift every day, so I would not recommend using this if you need to keep track of time. 

    It is important to know that the external LF crystal is optional on nRF52 based designs. The development kits have a crystal included, but if you make your own PCB, or buy some third party module, the crystal might not be included. 

    Best regards
    Torbjørn

Reply
  • Hi 

    Good to hear you figured out the reset issue Slight smile

    By internal RTC I assume you mean internal LF clock?

    Whether you are using app_timer, RTC0, RTC1 or RTC2 you have the choice of using the internal 32kHz RC oscillator, or using the external 32kHz crystal. 

    The external crystal will usually have an accuracy of 20ppm or better, which means you are looking at a worst case clock drift of 1.7 seconds pr day. 

    The internal LF oscillator is way less accurate, and can cause minutes or hours of drift every day, so I would not recommend using this if you need to keep track of time. 

    It is important to know that the external LF crystal is optional on nRF52 based designs. The development kits have a crystal included, but if you make your own PCB, or buy some third party module, the crystal might not be included. 

    Best regards
    Torbjørn

Children
  • Hi,

    Thanks for your reply.

    i'm using E73-2G4M04S1B module .

    it's have built-in 32.768 Khz clock crystal oscillator. 

    in my project initially, i have advertise then to communicate with android. After that enter into sleep.

    i want to keep RTC in sleep mode. particular time period based on RTC device need to wakeup.

    Here, app_timer is used for advertising sequence. RTC2 used for date & time function.

    RTC2 will operate in sleep mode ? how to wake up from sleep  using RTC?

    By default,RTC 0 is used for softdevice.

    Give better solution. If you have RTC with wakeup related examplemeans kindly share with us.

    Regards,

    Senthilkumar

  • Hi Senthilkumar

    The RTC timers will run fine in the standard system on idle sleep mode, triggered by calling sd_app_event_wait(). 

    Essentially any RTC interrupt will then wake you up from sleep. 

    This works the same for app_timers, so if you schedule an app_timer callback you can go to sleep, and the MCU will be woken up to run the app_timer callback. 

    You should be able to modify the calendar example to go to sleep in between events, you just have to add code to enter sleep in the for loop in main, 

    When not using the SoftDevice you can use the following code to enter system on idle sleep:

    __WFE();
    __SEV();
    __WFE();

    Best regards
    Torbjørn

  • Hi,

    I have read date & time using nrf_calendar(RTC2)  function.

    i have enable the app_timer interrupt functions below mentioned,

    app_timer_create(&awesome_timer, APP_TIMER_MODE_REPEATED, awesome_timeout_handler);
    app_timer_start(awesome_timer,APP_TIMER_TICKS(10000),NULL);

    after initialize, it will enter to idle_state_handle();

    Based on this timer, Every 10 sec once it will generate interrupt then i will start advertising after 10 sec stops the advertising.

    So, the Calendar functions also going well.

    After 1 hour this function will automatically reset and start from beginning.

    Here, i need date & Time continuously also need low power concept.

    give any other solutions.

    Regards,

    Senthilkumar

  • Hi,

    I suspect an assert is causing the fault handler to execute a system reset. That is really the only way for the chip to reset. So please enable DEBUG and check fault handler so you may find the file name, line number and error code causing the assert.

    Best regards,
    Kenneth

Related