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.

CC1352R: Wake-Up on RTC

Part Number: CC1352R
Other Parts Discussed in Thread: SYSBIOS

Hello,

my current project is a low-power system which read data from several sensors and send these data trhough RF. Now, my goal is to wake up my system every 10 minutes, acquire all needed data and at last send these ones to a reciever.

I want to use the RTC. What I found is this:
RTC has three different channels which work in specifics way (0 only in compare mode, 1 in capture mode and 2 in continous compare mode). I suppose that channel 2 is what I need but I am not capable of set RTC for this behaviour.

Right now I am able to do as follow:



void RTCInit(){

    /*Disable and Reset RTC*/
    AONRTCDisable();
    AONRTCReset();

    /*Clear event for and clear pending interrupt*/
    AONRTCEventClear(AON_RTC_CH0);
    IntPendClear(INT_AON_RTC_COMB);


    // Enable compare channel 0
    AONRTCCombinedEventConfig(AON_RTC_CH0);

    /* Set the compare value for the given channel*/
    AONRTCCompareValueSet(AON_RTC_CH0,0x00020000); // timing example

    /*Clear event for and clear pending interrupt*/
    AONRTCEventClear(AON_RTC_CH0);
    IntPendClear(INT_AON_RTC_COMB);

    /*Enable RTC_CH0 and RTC*/
    AONRTCChannelEnable(AON_RTC_CH0);
    AONRTCEnable();
}


And in my loop I call every time RTCInit().
This works but it is not good at all because it resets RTC every time. Moreover, this routine uses channel 0 and not channel 2 as I said before, if the settings are switched from channle 0 to channel 2 nothing happens.

Do you have any ideas for this issue? Moreover, how can I read the timing value of RTC?

best regards,
Vincenzo

  • Hi V,

    The RTC is setup and used by the TI-RTOS, while you could use channel 1, you would need to take care to not re-configure the RTC as this would affect all TI-RTOS related code.

    A better alternative is to use the Clock module provided by the TI-RTOS kernel. It runs of the RTC and give you an easy interface to setup timers which still allow low-power mode to be entered.

  • Hi M-W,

    thank you for your reply.

    So I should use the clock module to wake up my board every x min ?

    Searching on ti e2e forum I found this post:
    e2e.ti.com/.../3138861

    and it works fine. However, I need to be accurate and to timestamp every packet.

    The clock module Clock_getTick() returns a 32bit value starting from 0 since every start up. The value returned wraps back to zero after it reaches the maximum value that can be stored in 32 bits. (according to TI-RTOS Kernel SYS/BIOS User's Guide). So I suspect this is not good for my purpose.


    How can I read the proper RTC value in order to set a precise timestamp to my packet?
    Is there any example where is clearly used the RTC channels?

    Best regards,
    Vincenzo

  • Hi Vincenzo,

    You can always read out the free running RTC value and use that for timestamps using the DriverLib API:

    AONRTCCurrent64BitValueGet()

    For any timer related purposes, I suggest you go with clock to wake up the device, you will get the same resolution as trying to set channels yourself (there is a caveat for <  100us timers but this is not your use case). 

  • Hi M-W,

    thank you for your reply.
    I read out the RTC value using AONRTCCurrent64BitValueGet().

    I would like to understand better the meaning of RTC 64-bit value. As I can read from manuals they are 32-bit Seconds and 32-bit SubSeconds. OK, I got it. Indeed, if I write

    Seconds = (uint32_t)((AONRTCCurrent64BitValueGet() & 0xFFFFFFFF00000000) >> 32);


    I've got seconds.

    However, if I read the whole 64-bit data and try to convert it in a date format, I got

    t = AONRTCCurrent64BitValueGet() = 257694236672 => 03/02/1978 (mm/dd/yyyy) 14:43:57 (hh:mm:ss)

    Moreover, every time the Clock calls its callbackFxn the RTC 64-bit value skip ahead by years. The clock period is set for one minute so I expect to read the same date as before with an extra minute.
    regards,

    This seems to be a bit strange. Where am I wrong ?


    regards,
    Vincenzo

  • Hi Vencenzo, 

    How do you perform your calculations?

    A 64 bit value of 257694236672 would translate to 59,999 seconds. The conversion is something in line with:

    	
    Seconds = (uint32_t)((AONRTCCurrent64BitValueGet() & 0xFFFFFFFF00000000) >> 32);
    FracSeconds = (uint32_t)((AONRTCCurrent64BitValueGet() & 0x00000000FFFFFFFF) / (2^32));
    
    ActualTime = Seconds + FracSeconds;

  • Hi M-W,

    now I understand a little bit more about RTC. Before I confused the meaning of its value with unix epoch, so I tried to translate it into epoch value directly.

    If I want to do so I have to include ti/sysbios/hal/Seconds.h library and use Seconds_set(currentEpochValue) and Seconds_get()

    Thank you for your time and understanding.

    best regards,

    Vincenzo

  • That happens. You can use the "Seconds" module if you want a convenient API for seconds since start of epoch :)