Jump to content
43oh

Energia's Clock functionality for CC1310


Recommended Posts

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.

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!

 

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?

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.

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()
{ 
}
Link to post
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...