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.

RTOS/CC2650: How to use RTC?

Part Number: CC2650

Tool/software: TI-RTOS

Hi,

How to  RTC clock in CC2650? I am using CC2650 to trigger GPIO on predefined time. I want to know how to set RTC clock with actual time on system start up? Also is there a interrupt available from RTC where whole module will go to sleep once set work is performed and wake up again upon interrupt from RTC? Is there any example code on usage of RTC in CC2650?

  • Hi,

    you don't need use the RTC directly. You can use

    • The Seconds module in the TI-RTOS kernel to set a time base and get time stamps.
    • The Clock module in the TI-RTOS kernel to obtain exact events. The clock module is an abstraction on top of the RTC (represented by the Timer module). You can have as many "clocks" running as you want.

    I recommend using those. If you still think that this is not what you want, you may use the RTC directly. The RTC has 3 compare/match channels. Only channel 0 is used by TI-RTOS, channel 2 is used by sensor controller applications. The Timer module documentation contains a code snippet for this:

    TI-RTOS API doc said:

    The below snippets show an example of using Channel 1, with Driverlib API calls to configure an RTC event at 4 seconds after boot.
    First, in the application .cfg file a hook function is defined for Channel 1:

    var Timer = xdc.module('ti.sysbios.family.arm.cc26xx.Timer');
    Timer.funcHookCH1 = "&myHookCH1";

    In main(), Channel 1 is first cleared, a compare (match) value of 4 seconds is set, the channel is enabled, and is included (along with Channel 0) in the combined event configuration:

    AONRTCEventClear(AON_RTC_CH1);
    AONRTCCompareValueSet(AON_RTC_CH1, 0x40000);
    AONRTCChannelEnable(AON_RTC_CH1);
    AONRTCCombinedEventConfig(AON_RTC_CH0 | AON_RTC_CH1);

    With the above, myHookCH1() will be called when the RTC reaches a count of 4 seconds. At that time, a new compare value can be written for the next interrupt that should occur for Channel 1.