hello
i have task where i need blink leds
and for this function i cant use task_sleep()
Are there other options? for example " led1(1); delay(1000); led1(0) "
how i can get it?
This thread has been locked.
If you have a related question, please click the "Ask a related question" button in the top right corner. The newly created question will be automatically linked to this question.
hello
i have task where i need blink leds
and for this function i cant use task_sleep()
Are there other options? for example " led1(1); delay(1000); led1(0) "
how i can get it?
How about using a clock?
if you configure it to be periodic, you can blink the LED without using a task.
This thread gives a code example on how to use clock:
e2e.ti.com/.../346584
You just need to change the clockParams.period variable to a non-zero value to make your clock periodic (instead of one-shot).
If you look through the documentation in the installation folder of TI-RTOS, you can find all the functions that you can use with the clock module.
Michel
Here are the reasons why it doesn't work.
1- If you use the Clock_start() function behind the delay has expired, it will get reset and the clock callback function is never going to be called.
By putting clock_start inside a while loop, it will keep resetting itself.
2- When you create the clock, you have to supply a callback function which will be executed when the delay expires. The clock function that you provide as an argument cannot be itself.
That means that when the delay would expire, it wouldn't work. You would corrupt the stack, and even if it did, it would create an endless loop that would keep creating new clocks.
Also, by typecasting, you're just bypassing the protection which makes sure that you give it a proper function.
That means you have to create an extra function which has the same type as expected.
void fcntCallBack(UArg a)
{
//Do the periodic action here
}
You can look at the example (the link) again that I gave you in my previous answer.
Can you explain what each task has to do?
And how are they supposed to communicate or synchronize themselves (ex: clock timeout, button press, data received on the uart, etc.)?
And I would recommend that you stop typecasting the parameters that you pass to your functions (except when you pass a UArg as a void pointer or a void pointer itself). You are simply silencing the compiler which is warning you that you are doing something wrong.
In your case, you construct a clock task, but the function that you give does not have the same definition. It has to look the same as firstFxn.
Void clockFxn(UArg a0, UArg a1)
Just so you can get something working, add an empty while loop in clockFxn (it might not behave the way you want it to, but at least you'll have a clock working). Change its definition first and add a loop
Void clockFxn(UArg a0, UArg a1) {
//create your clock stuff here
Clock_start( ...... );
while (1) {
//do nothing, but keep task alive
}
}