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.

CC2340R5: How do I get CC2340R5 to wake-up from standby with an RTC compare event.

Part Number: CC2340R5

Tool/software:

Hello. I'm able to use the RTC to give me a periodic delay when I'm not in standby. However, once I enter standby, I no longer get the RTC compare callback.

Is there something else I need to do to wake-up from standby? I don't think I need to add a constraint to the Power mgr; it seems to me the RTC compare event is always enabled, but maybe that's no true.

void rtc_callback(uintptr_t arg)
{
    rtc_timeout_ticks += delay_ticks;
    HWREG(RTC_BASE + RTC_O_CH0CC8U) = rtc_timeout_ticks;
    GPIO_toggle((uint8_t)DIO_GREEN_LED);
}

int main()

   .....

    // Initialize our timer status for our compare timer
    memset((void *)&rtc_delay_node.hw_interrupt, 0, sizeof(HwiP_Struct));
    // Install the interrupt handler for the RTC.
    HwiP_Params rtc_params;
    HwiP_Params_init(&rtc_params);
    //rtc_params.arg = 0;
    //rtc_params.priority = INT_PRI_LEVEL2;
    HwiP_construct(&rtc_delay_node.hw_interrupt, INT_CPUIRQ0, rtc_private_isr_callback, &rtc_params);
    HWREG(EVTSVT_BASE + EVTSVT_O_CPUIRQ0SEL) = EVTSVT_CPUIRQ0SEL_PUBID_AON_RTC_COMB;

    // Update the run-time status for this timer
    delay_ticks = 2E6/8UL;

    // Adjust timeout value to be relative to the current time.
    rtc_timeout_ticks = HWREG(RTC_BASE + RTC_O_TIME8U) + delay_ticks;
    HWREG(RTC_BASE + RTC_O_CH0CC8U) = rtc_timeout_ticks;
    HwiP_enableInterrupt(INT_CPUIRQ0);

    // Enter the idle state
    Power_idleFunc();

  • I think I should add my power management code.

    Power_setDependency(PowerLPF3_PERIPH_GPIO);
    Power_enablePolicy();
    
    while (1)
    
    {
    
        Power_idleFunc();
    
    }

  • Hello Bob,

    I am still looking into the RTC code compare events, it should be possible to make this work similar to the code snippet below (but for me the ISR callback still is not going off)

    I am also invesgiating switching to the ClockP module as it syncs with the RCL for timing.

    #define RTC_PERIOD_MS 3000
    #define RTC_FREQ 31250 // 31.25 kHz
    HwiP_Struct rtcHwi;
    /* Driver configuration */
    #include "ti_drivers_config.h"
    void rtcInterruptHandler(uintptr_t arg) {
    if (HWREG(RTC_BASE + RTC_O_RIS) & RTC_RIS_EV0) {
    HWREG(RTC_BASE + RTC_O_ICLR) |= RTC_RIS_EV0;
    
    GPIO_toggle(CONFIG_GPIO_LED_0);
    HWREG(RTC_BASE + RTC_O_CTL) |= RTC_CTL_RST;
    }
    }
    /*
    * ======== mainThread ========
    */
    void *mainThread(void *arg0)
    {
    GPIO_init();
    uint32_t rtc_interval = RTC_PERIOD_MS * (RTC_FREQ / 1000);
    
    HWREG(RTC_BASE + RTC_O_CH0CC8U) = rtc_interval;
    
    HWREG(RTC_BASE + RTC_O_IMASK) |= RTC_RIS_EV0_S; //changed from 0x1 to 0x0
    
    HwiP_Params rtc_params;
    HwiP_Params_init(&rtc_params);
    rtc_params.arg = 0;
    rtc_params.priority = INT_PRI_LEVEL2;
    HwiP_construct(&rtcHwi, INT_CPUIRQ0, rtcInterruptHandler, &rtc_params);
    HwiP_enableInterrupt(INT_CPUIRQ0);
    
    HWREG(RTC_BASE + RTC_O_CTL) |= RTC_CTL_RST;
    HWREG(RTC_BASE + RTC_O_CTL) &= ~RTC_CTL_RST;
    
    Power_idleFunc();
    }

    Thanks,
    Alex F

  • Hello Bob,

    Creating a clock using the ClockP functions I was able to make a RTC synced clock that can wakeup the device every 6 seconds to toggle an LED, then return to low power (~700 nanoamps) 

    #include <ti/drivers/dpl/ClockP.h>
    /* Driver Header files */
    #include <ti/drivers/GPIO.h>
    // #include <ti/drivers/I2C.h>
    // #include <ti/drivers/SPI.h>
    // #include <ti/drivers/Watchdog.h>
    //#include <ti/drivers/dpl/ClockP.h>
    static ClockP_Struct clkStruct;
    ClockP_Handle clkHandle;
    ClockP_Params clockpParams;
    #define IME_UNIT  6000 //ms (to be modulated based on expected connection interval and signal quality)
    #define CLOCK_MS 1000
    /* Driver configuration */
    #include "ti_drivers_config.h"
    static void clockHandler(void)
    {
        GPIO_toggle(CONFIG_GPIO_LED_0);
    
    }
    /*
     *  ======== mainThread ========
     */
    void *mainThread(void *arg0)
    {
        /* 1 second delay */
        uint32_t time = 1;
        /* Call driver init functions */
        GPIO_init();
        ClockP_Params_init(&clockpParams);
        uint32_t clockTicks = IME_UNIT * (CLOCK_MS);
        clockpParams.period = clockTicks; //one-shot timer
        clockpParams.startFlag = true;
        clockpParams.arg = (uintptr_t)clockHandler;
        ClockP_create(*clockHandler, 0, &clockpParams);
        /* Configure the LED pin */
        GPIO_setConfig(CONFIG_GPIO_LED_0, GPIO_CFG_OUT_STD | GPIO_CFG_OUT_LOW);
    
        /* Turn on user LED */
        GPIO_write(CONFIG_GPIO_LED_0, CONFIG_GPIO_LED_ON);
    
        while (1)
        {
            //ClockP_sleep(time);
            Power_idleFunc();
        }
    }
    

    Thanks,
    Alex F

  • Hi Alex. Thank you.

    Using the clockP functions I am able to get the time delays I need while in standby. I'm still curious why we couldn't get the RTC to work as expected, but it's not something I need resolved.