Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Periodic Clock just firing the first time on CC1310 #7

Open
dberenguer opened this issue Feb 10, 2017 · 6 comments
Open

Periodic Clock just firing the first time on CC1310 #7

dberenguer opened this issue Feb 10, 2017 · 6 comments

Comments

@dberenguer
Copy link

dberenguer commented Feb 10, 2017

I'm trying to create a simple periodic timer based on Clock which should fire a callback every 5 seconds:

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

Clock_Params clkParams;
Clock_Struct clkStruct;
Clock_Handle clkHandle;
`
`
void setup()
{
  //...

  Clock_Params_init(&clkParams);
  clkParams.period = 5000000/Clock_tickPeriod;
  clkParams.startFlag = FALSE;

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

  //Clock_setTimeout(clkHandle, 5000000/Clock_tickPeriod); // Also tried with this function
  Clock_start(clkHandle);

  //...
}

But clkFxn is only called the first time after the initial timeout (5 sec)

void clkFxn(UArg arg0)
{
  digitalWrite(RED_LED, !digitalRead(RED_LED));
}
@rei-vilo
Copy link
Member

I confirm the issue. The Clock element of the Galaxia library no longer works.

@dberenguer
Copy link
Author

dberenguer commented Feb 14, 2017

I've found that the problem is in Clock_start(). Commenting this instruction out and setting clkParams.startFlag = TRUE makes the clock work as expected:

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

@rei-vilo
Copy link
Member

Does that mean that the delayed launch of the Clock is no longer possible?

See http://software-dl.ti.com/dsps/dsps_public_sw/sdo_sb/targetcontent/bios/sysbios/6_42_01_20/exports/bios_6_42_01_20/docs/cdoc/

@dberenguer
Copy link
Author

Not in an asynchronous way, as you were doing with Galaxia.

@rei-vilo
Copy link
Member

Strange, as it used to work with the Clock_start fired after Clock_create.

@dberenguer
Copy link
Author

I was using Clock_construct instead of Clock_create.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants