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

nrf52832 rtc to timestamp

Hello,

I am using nRF52832 chip for freeRTOS project and using RTC2. I have SDK15.2. I want to have timestamp from RTC as hex format. I searched almost all forums but i have nothing.  I just found https://github.com/NordicPlayground/nrf5-calendar-example this example but i want to uptade automatically and don't want to update via bluetooth. Could you recommend me some examples or forum? 

Thanks

  • I am reading accelerometer sensor datas and trying to find max 5 value in 10 secs. I have to know when i get this 5 max values so i want to put timestamp info after values.

    Best regards

  • I still think you should look at the calendar example to see how the RTC is initialized and how the timestamp function(s) are implemented, and then implement that into your project with this accelerometer sensor data.

    Please be more specific with what you're having trouble with.

    Best regards,

    Simon

  • ı implemented the calendar example to my project but i have an error when header file is like this :

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

    Error is Output/.../....o: in function `RTC2_IRQHandler':multiple definition of `RTC2_IRQHandler';

    ...\nRF5_SDK_15.2.0_9412b96\modules\nrfx\drivers\src/nrfx_rtc.c:343: first defined here

    Then i change the header file, code just stop :

    #define CAL_RTC NRF_RTC0
    #define CAL_RTC_IRQn RTC0_IRQn
    #define CAL_RTC_IRQHandler RTC0_IRQHandler
    #define CAL_RTC_IRQ_Priority 3

    Here is my implementation :

    void NrfInit(void)
    {
    /* Select the 32 kHz crystal and start the 32 kHz clock */
    NRF_CLOCK->LFCLKSRC = CLOCK_LFCLKSRC_SRC_Xtal << CLOCK_LFCLKSRC_SRC_Pos;
    NRF_CLOCK->EVENTS_LFCLKSTARTED = 0;
    NRF_CLOCK->TASKS_LFCLKSTART = 1;
    //while(NRF_CLOCK->EVENTS_LFCLKSTARTED == 0);

    /* Configure the RTC for 1 minute wakeup (default) */
    CAL_RTC->PRESCALER = 0xFFF;
    CAL_RTC->EVTENSET = RTC_EVTENSET_COMPARE0_Msk;
    CAL_RTC->INTENSET = RTC_INTENSET_COMPARE0_Msk;
    CAL_RTC->CC[0] = m_rtc_increment * 8;
    CAL_RTC->TASKS_START = 1;
    NVIC_SetPriority(CAL_RTC_IRQn, CAL_RTC_IRQ_Priority);
    NVIC_EnableIRQ(CAL_RTC_IRQn);
    }

    void nrf_cal_set_callback(void (*callback)(void), uint32_t interval)
    {
    /* Set the calendar callback, and set the callback interval in seconds */
    cal_event_callback = callback;
    m_rtc_increment = interval;
    m_time += CAL_RTC->COUNTER / 8;
    CAL_RTC->TASKS_CLEAR = 1;
    CAL_RTC->CC[0] = interval * 8;
    }

    void CAL_RTC_IRQHandler(void)
    {
    if(CAL_RTC->EVENTS_COMPARE[0])
    {
    CAL_RTC->EVENTS_COMPARE[0] = 0;

    CAL_RTC->TASKS_CLEAR = 1;

    m_time += m_rtc_increment;
    if(cal_event_callback) cal_event_callback();
    }
    }

    Best regards

  • Hi

    Well, it seems like you have defined RTC2_IRQHandler multiple times in your project. Please find out which one you need for your project and remove the other one. What do you mean by "Then I change the header file, code just stop"? Where does it stop exactly, and how does it stop? Have you tried debugging to find out if you can see an error of some kind?

    Best regards,

    Simon

Related