This thread has been locked.

If you have a related question, please click the "Ask a related question" button in the top right corner. The newly created question will be automatically linked to this question.

CC2651R3SIPA: How to create RTC callback function

Part Number: CC2651R3SIPA


Tool/software:

Hi expert,

I would like to create a wake-up function every 10 minutes using rtc.

i made it as below by referring to several e2e forums, but it seems that rtc callback is not called.

could you point out the error?

void AON_RTChandling_createTask(void)
{
  setupRTC();
}

void setupRTC(void) {

AONRTCDisable();
AONRTCReset();
AONRTCEventClear(AON_RTC_CH0);

AONRTCCompareValueSet(AON_RTC_CH0, AONRTCCurrent64BitValueGet() + RTC_INTERVAL_TICKS);
IntPendClear(INT_AON_RTC_COMB);
AONRTCChannelEnable(AON_RTC_CH0);
AONRTCEnable();
AONRTCCombinedEventConfig(AON_RTC_CH0 | AON_RTC_CH1 | AON_RTC_CH2);

//AONEventMcuWakeUpSet(AON_EVENT_MCU_WU0, AON_EVENT_RTC_CH1);

HwiP_Params hwiParams;
HwiP_Params_init(&hwiParams);
hwiParams.priority = 1;
HwiP_create(INT_AON_RTC_COMB, rtcCallback, &hwiParams);

HwiP_enableInterrupt(INT_AON_RTC_COMB);

GPIO_setConfig(CONFIG_TEST_LED, GPIO_CFG_OUT_STD | GPIO_CFG_OUT_HIGH);

}

void rtcCallback(uintptr_t arg) {
dispHandle = Display_open(Display_Type_ANY, NULL);
Display_printf(dispHandle, 0, 0, " rtcCallback ");

AONRTCEventClear(AON_RTC_CH0);

GPIO_toggle(CONFIG_TEST_LED);

uint32_t nextTick = AONRTCCurrentCompareValueGet() + RTC_INTERVAL_TICKS;
AONRTCCompareValueSet(AON_RTC_CH1, nextTick);

HwiP_clearInterrupt(INT_AON_RTC_COMB);
}

thanks 

B.R

  • Hello Moon,

    I hope you are doing well, I will try to look into your issue further, and recrate something on my side.

    Thanks,
    Alex F

  • Hello Moon,

    I wanted to ask if we could use the Timer peripheral here to help, found in TimerPCC26XX_nortos.c? With that being said this timer function does very similar steps to your implementation. 

        /* Add current time to compare-value, in case it is not 0 */
        compare += AONRTCCurrentCompareValueGet();

        /* Clear events on channel 0 */
        AONRTCEventClear(AON_RTC_CH0);

        /* set the compare value at the RTC */
        AONRTCCompareValueSet(AON_RTC_CH0, compare);

        /* enable compare channel 0 */
        AONEventMcuWakeUpSet(AON_EVENT_MCU_WU0, AON_EVENT_RTC0);

        AONRTCChannelEnable(AON_RTC_CH0);
    Thanks,
    Alex F
  • Hi Alex.

    thanks for reply.

    I can't see the Callback function for the RTC event on your source you sent me.

    please tell me how to implement even callback or interrupt handler.

    we have to wake up with RTC and then perform certain actions.

    thanks

    B.R

  • Hello B.R

    We should be able to use the timer function here and have a global increment every second. Something like:

    Timer_Handle    handle;
    Timer_Params    params;
    Timer_Params_init(&params);
    params.periodUnits = Timer_PERIOD_HZ;
    params.period = 1;
    params.timerMode  = Timer_CONTINUOUS_CALLBACK;
    params.timerCallback = UserCallbackFunction;
    handle = Timer_open(CONFIG_TIMER0, &params);
    if (handle == NULL) {
        // Timer_open() failed
        while (1);
    }
    status = Timer_start(handle);
    if (status == Timer_STATUS_ERROR) {
        //Timer_start() failed
        while (1);
    }
    sleep(10000);
    Timer_stop(handle);

    Thanks,
    Alex F

  • Hi Alex

    the callback fuction you sent me is a setting for general TImer.

    please let me know how to set up RTC Callback and RTC configuration.

    thanks

  • Hello Robin,

    I found the following thread which discusses a similar topic (RTC wakeup), this should be useful in setting up your version:

    https://e2e.ti.com/f/1/t/884941/

    Thanks,
    Alex F