Jump to content


Photo

Energia's Clock functionality for CC1310

Energia CC1310 clock

  • Please log in to reply
6 replies to this topic

#1 estratos

estratos

    Member

  • Members
  • PipPip
  • 27 posts
  • LocationBadajoz (Spain)

Posted 08 February 2017 - 12:04 PM

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.



#2 Rei Vilo

Rei Vilo

    Level 4

  • Members
  • 1,235 posts
  • LocationFrance

Posted 08 February 2017 - 09:10 PM

Have you had a look at the Galaxia library?

http://embeddedcompu...th-galaxia.html
https://github.com/r...Galaxia_Library

#3 estratos

estratos

    Member

  • Members
  • PipPip
  • 27 posts
  • LocationBadajoz (Spain)

Posted 09 February 2017 - 04:36 PM

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!

 



#4 Rei Vilo

Rei Vilo

    Level 4

  • Members
  • 1,235 posts
  • LocationFrance

Posted 09 February 2017 - 07:36 PM

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?



#5 estratos

estratos

    Member

  • Members
  • PipPip
  • 27 posts
  • LocationBadajoz (Spain)

Posted 10 February 2017 - 12:40 PM

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.



#6 Rei Vilo

Rei Vilo

    Level 4

  • Members
  • 1,235 posts
  • LocationFrance

Posted 11 February 2017 - 06:54 AM

@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.



#7 estratos

estratos

    Member

  • Members
  • PipPip
  • 27 posts
  • LocationBadajoz (Spain)

Posted 14 February 2017 - 12:18 PM

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()
{ 
}






Also tagged with one or more of these keywords: Energia, CC1310, clock

0 user(s) are reading this topic

0 members, 0 guests, 0 anonymous users