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/CC1310: NoRTOS Clock module without jitter

Part Number: CC1310

Tool/software: TI-RTOS

Hello.

There is a simple example of using clock in NoRTOS mode using a semaphore. I need to get accurate time interruptions. As a result, I get jitter 34 mks, and sometimes 174 mks, both in a positive and in a negative direction. 
For me it is very critical. How do I make stable low-power clock interruptions without jitter?
/*
 *  ======== main_nortos.c ========
 */
#include <stdint.h>
#include <stddef.h>
#include <NoRTOS.h>
#include <ti/drivers/Board.h>
#include <ti/drivers/Power.h>
#include <ti/drivers/GPIO.h>
#include <ti/drivers/dpl/ClockP.h>
#include <ti/drivers/dpl/SemaphoreP.h>
#include "Board.h"

uint32_t Clock_tickPeriod = 1; // 1 mks
ClockP_Struct clkStruct;
ClockP_Handle clkHandle;
SemaphoreP_Handle mainSemaphore;

/*
 *  Clock callback fnx
 */
void MainClockFxn(uintptr_t arg)
{
    SemaphoreP_post(mainSemaphore);
}

/*
 *  ======== main ========
 */
int main(void)
{
    NoRTOS_Config cfg;

    NoRTOS_getConfig(&cfg);
    cfg.clockTickPeriod = Clock_tickPeriod;
    cfg.idleCallback = Power_idleFunc;
    NoRTOS_setConfig(&cfg);

    /* Call driver init functions */
    Board_init();

    /* Start NoRTOS */
    NoRTOS_start();

    GPIO_init();
    GPIO_setConfig(Board_GPIO_LED0, GPIO_CFG_OUT_STD | GPIO_CFG_OUT_LOW);

    // Init Semaphore
    SemaphoreP_Params params;
    SemaphoreP_Params_init(&params);
    params.mode = SemaphoreP_Mode_BINARY;
    mainSemaphore = SemaphoreP_create(0, &params);
    if(mainSemaphore == NULL) {
        while(1); // stop program
    }

    // Init Clock
    ClockP_Params clkParams;
    ClockP_Params_init(&clkParams);
    uint32_t period = 10000/Clock_tickPeriod; // period = 10 ms
    clkParams.period = period;
    clkParams.startFlag = false;
    ClockP_construct(&clkStruct, (ClockP_Fxn)MainClockFxn, period, &clkParams);
    clkHandle = ClockP_handle(&clkStruct);
    ClockP_start(clkHandle);

    //
    while (1) {
        GPIO_toggle(Board_GPIO_LED0);
        SemaphoreP_pend(mainSemaphore, SemaphoreP_WAIT_FOREVER );
    };

    return 0;
}

  • Hi,

    With the approach you chose you experience jitter due to propagation time of the RTC interrupts through the different software levels. In most of the application this is not a problem (but obviously it is a problem for you).

    To avoid the jitter, I would recommend to directly using the “raw” RTC interrupts. The NoRTOS DPL already implement the RTC as part of the TimerP module (much like TI-RTOS does).You have to be careful when setting up additional RTC interrupts/events as this could interfere with the TimerP module (could potentially mess up all the device timing).

    I would suggest you have a look inside TimerPCC26XX_nortos.c and see how NoRTOS uses the AONRTC DriverLib. From this point, you could possibly extend it to feature more channels and events if you need to.

    Unfortunately, I have no example to provide but you can have a look to the following E2E thread:

    https://e2e.ti.com/support/wireless-connectivity/sub-1-ghz/f/156/t/710343?CC1310-RTC-in-NORTOS-cc1310

    Best regards,