estratos 5 Posted February 8, 2017 Share Posted February 8, 2017 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. Quote Link to post Share on other sites
Rei Vilo 695 Posted February 8, 2017 Share Posted February 8, 2017 Have you had a look at the Galaxia library? http://embeddedcomputing.weebly.com/exploring-rtos-with-galaxia.html https://github.com/rei-vilo/Galaxia_Library Quote Link to post Share on other sites
estratos 5 Posted February 9, 2017 Author Share Posted February 9, 2017 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! Quote Link to post Share on other sites
Rei Vilo 695 Posted February 9, 2017 Share Posted February 9, 2017 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? Quote Link to post Share on other sites
estratos 5 Posted February 10, 2017 Author Share Posted February 10, 2017 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. Quote Link to post Share on other sites
Rei Vilo 695 Posted February 11, 2017 Share Posted February 11, 2017 @@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. Quote Link to post Share on other sites
estratos 5 Posted February 14, 2017 Author Share Posted February 14, 2017 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() { } Quote Link to post Share on other sites
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.