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.

cc2642R - Very exact timing of 100ms - interrupt



Hello,

I am working on a project that requires a very accurate timer/clock. I need a periodic interrupt every 100ms to read counter to calculate incoming frequency.

The code i am using today shifts with about 2ms when i measured with a oscilloscope. Does anyone know how to get a more accurate interrupt?

As you can see from the code below, I made sure the external crystal is used.

void *main_control_task(void *arg0, void *arg1)
{
    UNUSED(arg0);
    UNUSED(arg1);

    main_control_initialise_event();

    (void)rtc_init(0);


    OSCHF_TurnOnXosc();

    while(!OSCHF_AttemptToSwitchToXosc())
    {
    }

    while(1)
    {
// .......
// customer code
// ......
    }



static void measurement_clock_init(void)
{
    uint32_t period = 100 * (1000 / ClockP_getSystemTickPeriod()) + 2;
    /* Construct BIOS Objects */
    Clock_Params clkParams;

    Clock_Params_init(&clkParams);
    clkParams.period = period;
    clkParams.startFlag = TRUE;

    /* Construct a periodic Clock Instance */
    Clock_construct(&clk0Struct, (Clock_FuncPtr)measurement_cb,
                    period *10U, &clkParams);

}

Any response is appreciated.

Thx,

Ole

  • Hello Ole,

    Are you using a LP-CC2642R or custom board?  Have you tuned the HF oscillator using the internal cap-array as described in Section 6.4 of SWRA640?  How are you verifying that the interrupts are diverging from 100 ms?  Have you tried modifying the period slightly to achieve the interrupt timing required?

    Regards,
    Ryan

  • Hello Ryan and thanks for such a quick response.

    I now see a fault in my initial post. The fault is 0.2ms, not 2ms. We are measuring frequencies up to 500kHz. So the total fault could be up to 1kHz, which is to much (if the interrupt is consistently 0.2ms off).

    We are using a custom board.

    CCFG are set to "#define SET_CCFG_MODE_CONF_XOSC_CAP_MOD 0x1 // Don't apply cap-array delta". But have not done more than that.

    To measure the time of the interrupts, i made the interrupt handler toggle a GPIO connected to a test point on the board, then connected a oscilloscope to the test point for monitoring. Will try to attach a picture to this post.

    As you see from the initial code, i added 2 systemticks to the timer to make it closer to 100ms.

    Regards,

    Ole

  •  This is how the crystal is mounted on our custom board.

  • You should consider evaluating a LAUNCHXL-CC26X2R1 to determine whether behavior is any different with this hardware, reference SWRA495 for crystal oscillator recommendations, and also submit your hardware design to SIMPLELINK-2-4GHZ-DESIGN-REVIEWS for further review.

    Regards,
    Ryan