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/CC2650STK: Interrupt every 1msec

Part Number: CC2650STK
Other Parts Discussed in Thread: SYSBIOS

Tool/software: TI-RTOS

Hi,

I want to run a function every 1msec. I used the sample of clock_CC2650STK and used the periodic timer but I don't know how I can set the setting to have 1msec.

The example define the clock as Clock_construct(&clk0Struct, (Clock_FuncPtr)clk0Fxn,5000/Clock_tickPeriod, &clkParams);

and clkParams.period = 50000/Clock_tickPeriod but I have no idea what is the 5000/Clock_tickPeriod. and what is he value of Clock_tickPeriod. How I can change the setting to have 1msec.

And Also, I want to put the module in idle to lower power consumption and wake up after 1msec do something and then sleep.

Could you please give me an example about that.

Thanks.

  • Hi Asad,

    The Clock Params tick period, and the timeout passed to Clock_construct(), are given in Clock ticks.  Clock_tickPeriod is in microseconds.  So if you want a period of 1 msec = 1000 usecs, you need to set clkParams.period = 1000 / Clock_tickPeriod.

    You can find more documentation in the SYS/BIOS cdoc for ti.sysbios.knk.Clock.  There is also some information about the kernel Clock example in the README.html file.

    The Power module is enabled in the board file, so the device should go into low power mode if it's not busy.

    Best regards,

    Janet

  • Hi,

    I just modified my code to make sure that it is working correctly and show the system time at each 5 seconds. But the time between printing the system time is around 10seconds.

    This is my code:

    Clock_Params clkParams;
    
        /* Call board init functions */
        Board_initGeneral();
    
        Clock_Params_init(&clkParams);
        clkParams.period = 5000000/Clock_tickPeriod;
        clkParams.startFlag = TRUE;
    
        /* Construct a periodic Clock Instance */
        Clock_construct(&clk0Struct, (Clock_FuncPtr)clk0Fxn,
                        5000000/Clock_tickPeriod, &clkParams);
        clkParams.period = 0;
        clkParams.startFlag = TRUE;
        clk2Handle = Clock_handle(&clk0Struct);
    
        Clock_start(clk2Handle);

    And this is clk0Fxn function:

    Void clk0Fxn(UArg arg0)
    {
        UInt32 time;
        count=count+1;
        time = Clock_getTicks();
        System_printf("System time in clk0Fxn = %lu\n", (ULong)time);
        //taskFxn();
        System_flush();
    }

    based on my code, the sensor is supposed to print the time every 10 second but it seems that it takes more time.

  • Hi Asad,

    I tried running a similar program on a 2650 Launchpad, and it's printing out the time about every 5 seconds.  Here is the output I'm getting:

    System time in clk0Fxn = 500007
    System time in clk0Fxn = 1000006
    System time in clk0Fxn = 1500011
    System time in clk0Fxn = 2000006
    System time in clk0Fxn = 2500011

    Are you getting similar output?

    Best regards,

    Janet

  • The output is correct, but when I use my digital watch it is not really 5 seconds (it's between 7 to 8 sec) , it seems that each Clock_tickPeriod is not accurately 1usec.
  • Hi Asad,
    I think the System_printf() may be adding to the time. Can you try toggling an LED in your clock function instead of calling System_printf()? You can copy code from the drivers 'empty' example to toggle the LED.
    Best regards,
    Janet