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:如何通过 RTC 比较事件使 CC2340R5从待机状态唤醒。

Guru**** 2386700 points
请注意,本文内容源自机器翻译,可能存在语法或其它翻译错误,仅供参考。如需获取准确内容,请参阅链接中的英语原文或自行翻译。

https://e2e.ti.com/support/wireless-connectivity/other-wireless-group/other-wireless/f/other-wireless-technologies-forum/1500766/cc2340r5-how-do-i-get-cc2340r5-to-wake-up-from-standby-with-an-rtc-compare-event

器件型号:CC2340R5

工具/软件:

你好。 当我不处于待机状态时、我可以使用 RTC 定期延迟。 但是、一旦进入待机模式、我就不再获得 RTC 比较回调。

是否还需要执行其他操作才能从待机状态唤醒? 我认为我不需要向电源管理器添加约束;在我看来、RTC 比较事件始终处于启用状态、但可能不是这样。

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();

  • 请注意,本文内容源自机器翻译,可能存在语法或其它翻译错误,仅供参考。如需获取准确内容,请参阅链接中的英语原文或自行翻译。

    我想我应该添加电源管理代码。

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

  • 请注意,本文内容源自机器翻译,可能存在语法或其它翻译错误,仅供参考。如需获取准确内容,请参阅链接中的英语原文或自行翻译。

    您好 Bob:

    我仍在研究 RTC 代码比较事件、应该可以使其工作类似于下面的代码片段(但对于我来说、ISR 回调仍然不会关闭)

    我还计划切换到 ClockP 模块、因为它与 RCL 进行计时同步。

    #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();
    }

    谢谢、
    Alex F

  • 请注意,本文内容源自机器翻译,可能存在语法或其它翻译错误,仅供参考。如需获取准确内容,请参阅链接中的英语原文或自行翻译。

    您好 Bob:

    使用 ClockP 功能创建时钟我能够制作一个 RTC 同步时钟、该时钟可以每6秒唤醒一次器件以切换 LED、然后恢复到低功耗(~700纳安)。  

    #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();
        }
    }
    

    谢谢、
    Alex F

  • 请注意,本文内容源自机器翻译,可能存在语法或其它翻译错误,仅供参考。如需获取准确内容,请参阅链接中的英语原文或自行翻译。

    您好 Alex。 谢谢你。

    使用 clockP 功能、我能够获得待机时所需的延时时间。 我仍然很好奇、为什么我们无法按预期运行 RTC、但这不是我需要解决的问题。