• Announcements

    • bluehash

      Forum Upgrade   03/11/2017

      Hello Everyone, Thanks for being patient while the forums were being fixed and upgraded. Please see details and report issues in this thread. Thanks!
estratos

Energia's Clock functionality for CC1310

7 posts in this topic

I'm trying to test the clock functionality available on TIRTOS for the CC1310 SOC from Energia but I'm finding difficulties to make the clock trigger periodically (every 5 seconds in the example). This is what I'm doing so far:

  #include <ti/sysbios/knl/Clock.h>
  #include <ti/sysbios/BIOS.h>

  Clock_Params clkParams;
  Clock_Struct clkStruct;
  Clock_Handle clkHandle;
Clock_Params_init(&clkParams);
clkParams.period = 5000000/Clock_tickPeriod;
clkParams.startFlag = FALSE;
/* Construct a periodic Clock Instance */
Clock_construct(&clkStruct, (Clock_FuncPtr)clkFxn, 5000000/Clock_tickPeriod, &clkParams);
clkHandle = Clock_handle(&clkStruct);
Clock_setTimeout(clkHandle, 5000000 / Clock_tickPeriod);
Clock_start(clkHandle);

I wonder whether Energia is overwriting Clock in some way.

 

Thanks for your ideas,

 

Daniel.

Share this post


Link to post
Share on other sites

Hi Rei,

 

I was never able to try with Galaxia library due to some compiling problems. In any case, I've verified that you are following the same strategy as me to drive the Clock function. First you fill clkParams, then create or construct the clock object and finally start the clock. The only difference is that you are directly entering msec into clkParams.period and  ClockTimeOut_ms. This is weird in fact since I've verified that ClockTimeOut needs to be specified in microseconds/Clock_tickPeriod.

 

What happens after running clock_start() is that the callback function is called after ClockTimeOut but nothing else. It's like clkParams.period takes no effect at all.

 

Thanks!

 

Share this post


Link to post
Share on other sites

I was never able to try with Galaxia library due to some compiling problems. 

 

 

That's really surprising. I'm using the Galaxia library on a daily basis, and projects compile successfully with both Energia 18 and embedXcode.

 

 

The only difference is that you are directly entering msec into clkParams.period and  ClockTimeOut_ms. 

 

The explanation comes from the value of Clock_tickPeriod. I agree, it is not the cleanest implementation.

Clock_tickPeriod = 1000

What happens after running clock_start() is that the callback function is called after ClockTimeOut but nothing else. It's like clkParams.period takes no effect at all.

 

With MSP432 board package 3.8.0, the clock runs one time but freezes after.

*** Clock Library
FreqHz.hi = 0
FreqHz.lo = 48000000
Clock_tickPeriod = 1000
myClock.begin... done
myClock.start... done
# 0,    us = 3599

# 1,    us = 986661 - 3599 = 983062
# 2,    us =

Have you posted the question on the E2E forum and reported the issue on the GitHub Energia repository?

Share this post


Link to post
Share on other sites

Hi Rei,

 

The compiler complained about some lacking .h resources for the MSP432 but I was building for the CC1310 in fact.

 

With MSP432 board package 3.8.0, the clock runs one time but freezes after.

 

Have you posted the question on the E2E forum and reported the issue on the GitHub Energia repository?

 

Yes, I've posted the question in the TI forum but they are suggesting that probably Energia was overwriting some of the functions. I'm now going to open an issue on GitHub.

 

Thanks again Rei for your time,

 

Daniel.

Share this post


Link to post
Share on other sites

@@estratos

 

There is another RTOS element you can try: the Timer, also included in the Galaxia library.

 

However, one timer needs to be available. 

 

For the MSP432, the MCU features 4 timers but 3 are already used.

 

I don't know how many timers CC1310 features, and how many timers Energia already uses.

Share this post


Link to post
Share on other sites

I found that commenting Clock_start() out and setting clkParams.startFlag = TRUE does make the clock periodically call the user function:

#include <ti/sysbios/knl/Clock.h>
#include <ti/sysbios/BIOS.h>

Clock_Params clkParams;
Clock_Struct clkStruct;
Clock_Handle clkHandle;
    
void clkFxn(UArg arg0)
{
  digitalWrite(RED_LED, !digitalRead(RED_LED));
}

void setup()
{
  pinMode(RED_LED, OUTPUT);
  digitalWrite(RED_LED, HIGH);
  
  Clock_Params_init(&clkParams);
  clkParams.period = 5000000/Clock_tickPeriod;
  clkParams.startFlag = TRUE;

  Clock_construct(&clkStruct, (Clock_FuncPtr)clkFxn, 5000000/Clock_tickPeriod, &clkParams);

  //Clock_start(clkHandle);
}

void loop()
{ 
}

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!


Register a new account

Sign in

Already have an account? Sign in here.


Sign In Now