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.

[参考译文] CC1312R:如何将 RTC 通道1和2与 TI-RTOS7配合使用?

Guru**** 2540720 points
Other Parts Discussed in Thread: SYSBIOS, SYSCONFIG

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

https://e2e.ti.com/support/wireless-connectivity/sub-1-ghz-group/sub-1-ghz/f/sub-1-ghz-forum/1158141/cc1312r-how-to-use-rtc-channel-1-and-2-with-ti-rtos7

器件型号:CC1312R
Thread 中讨论的其他器件:SysBIOSSysConfig

您好!

我有一个基于'old' TI-RTOS (而非7)的项目仍在开发中、该项目使用 RTOS 提供的挂钩来与 RTC CH1和 CH2硬件配合使用。  

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:
    AONRTCEventClear(AON_RTC_CH1);
    AONRTCCompareValueSet(AON_RTC_CH1, 0x40000);
    AONRTCChannelEnable(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.

有计划在项目的稍后阶段迁移到新的 TI-RTOS7、因此请向我提供一些信息 、RTC CH1和 CH2如何与新的 TI-RTOS7配合使用?   

此致、

Dimitar Devedzhiev

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

    您好、Dimitar、

    在 TI-RTOS7中、我建议您使用 tiposix 层来访问 RTC。 尤其是、您应该使用 ClockP 模块来设置计时器和管理延迟。  

    下面是一个有关如何使用 ClockP 设置1秒周期性回调的示例、但您也可以调整参数以将其设置为一次性回调。

    这只是空示例的修改版本,以使用 ClockP 而不是 sleep()来切换红色 LED。

    /*
     * Copyright (c) 2015-2019, Texas Instruments Incorporated
     * All rights reserved.
     *
     * Redistribution and use in source and binary forms, with or without
     * modification, are permitted provided that the following conditions
     * are met:
     *
     * *  Redistributions of source code must retain the above copyright
     *    notice, this list of conditions and the following disclaimer.
     *
     * *  Redistributions in binary form must reproduce the above copyright
     *    notice, this list of conditions and the following disclaimer in the
     *    documentation and/or other materials provided with the distribution.
     *
     * *  Neither the name of Texas Instruments Incorporated nor the names of
     *    its contributors may be used to endorse or promote products derived
     *    from this software without specific prior written permission.
     *
     * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
     * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
     * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
     * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR
     * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
     * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
     * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
     * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
     * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
     * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE,
     * EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
     */
    
    /*
     *  ======== empty.c ========
     */
    
    /* For usleep() */
    #include <unistd.h>
    #include <stdint.h>
    #include <stddef.h>
    
    /* Driver Header files */
    #include <ti/drivers/GPIO.h>
    // #include <ti/drivers/I2C.h>
    // #include <ti/drivers/SPI.h>
    // #include <ti/drivers/Watchdog.h>
    
    /* Driver configuration */
    #include "ti_drivers_config.h"
    
    #include <ti/drivers/dpl/ClockP.h>
    
    
    void clkCallback(uintptr_t arg0){
    
        GPIO_toggle(CONFIG_GPIO_LED_0);
    }
    
    
    
    /*
     *  ======== mainThread ========
     */
    void *mainThread(void *arg0)
    {
        /* 1000 second delay */
        uint32_t time = 1000;
    
        ClockP_Struct clkStruct;
        ClockP_Params clkParams;
        ClockP_Handle clkHandle = NULL;
    
        ClockP_Params_init(&clkParams);
    
        clkParams.period = 100000; // 100k RTC ticks (10us each) = 1s
        clkParams.startFlag = true; // start clock immediately after instance is created
    
        clkHandle = ClockP_construct(&clkStruct, clkCallback, 0, &clkParams);
    
        /* Call driver init functions */
        GPIO_init();
        // I2C_init();
        // SPI_init();
        // Watchdog_init();
    
        /* 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)
        {
            sleep(time);
        }
    }
    

    您可以在中找到有关 tiposix 调用的其他文档 /source/ti/drivers/dpl/ClockP.h

    此致、

    高斯图

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

    您好、Fausto、

    我不是在问如何使用时钟对象、而是在问 TI_RTOS7是否直接使用 RTC 通道1和通道2。

    我正在使用 RTC CH1捕获来捕获外部事件的 RTC 时间、并使用 CH2自动比较加载功能来生成时间段、该时间段不会因 HWI 或 SWI 进入延迟而产生漂移(可能存在抖动、但不会漂移)。    

    之前版本的 TI-RTOS 提供了 ti.sysbios.family.arm.cc26xx.Timer 模块内的挂钩函数。

    那么、我的问题是 RTC CH1和 CH2硬件如何 与新的 TI-RTOS7一起使用、而不是与时钟对象一起使用?   

    此致、

    Dimitar

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

    您好、Dimitar、

    很抱歉、我误解了您的问题。

    您可以在 SysConfig 接口中找到 RTC 通道1和通道2的挂钩、如下所示:

    实际上、如果您从文件"sdk_dir\kernel\tirtos7\packages/ti\sysBIOS\family\arm\cc26xx\Timer.h"中获取原始帖子中的片段、则该文档不精确、将在即将发布的下一个 SDK 6.30中更新为以下内容:

     * The below snippets show an example of using Channel 1, with Driverlib API
     * calls to configure an RTC event at 4 seconds after boot.
     *
     * With Syscfg open, the hook function for Channel 1 can be set to a user-defined
     * function under:
     * Clock->Other Dependencies->Clock Support->Other Dependencies->RTC Timer->
     * RTC Channel 1 function hook
     *
     * In main(), Channel 1 is first cleared, a compare (match) value of 4 seconds
     * is set, the channel is enabled:
     *
     * @code
     *    AONRTCEventClear(AON_RTC_CH1);
     *    AONRTCCompareValueSet(AON_RTC_CH1, 0x40000);
     *    AONRTCChannelEnable(AON_RTC_CH1);
     * @endcode

    希望这对您有所帮助。

    此致、

    高斯图