Other Parts Discussed in Thread: SYSBIOS
Hi team,
I am working with cc2650 in that how to blink the led by using Task_sleep() and also can you explain about this
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.
HI Yikai,
Thank you so much for the reply,I tried it but it is not working
int rcnt = 0;
for(rcnt = 10; rcnt > 0; rcnt--)
{
//Task_sleep(50000 / Clock_tickPeriod);
PIN_setOutputValue(ledPinHandle,Board_LED0, 0);
Task_sleep(1000*(1000 / Clock_tickPeriod));
PIN_setOutputValue(ledPinHandle,Board_LED0, 0);
Task_sleep(1000*(1000 / Clock_tickPeriod));
//PIN_setOutputValue(ledPinHandle,Board_LED0, 0);
}
rcnt = 0;
Since you use PIN_setOutputValue(ledPinHandle,Board_LED0, 0) before and after Task_sleep, it's normal not to see blinking. Shouln't you change one of two PIN_setOutputValue(ledPinHandle,Board_LED0, 0) to PIN_setOutputValue(ledPinHandle,Board_LED0, 1)?
Thank you reply,
I am doing a small project in that I want to implement some this like, while long-press button led should blinking continuously once it is released it should off. But it works when I am using CPUDELAY() but when I used Tasksleep() it is not working
You can start a periodic timer event to toggle led (which should look like blinking) when button is pressed and stop periodic event to stop blinking when button is released.
You can refer to https://sunmaysky.blogspot.com/2018/12/how-to-detect-buttont-hold-in-cc26x2.html for button hold and release implementation. Based on previous example, you can create periodic event to toggle led. For periodic event, you can refer to SP_PERIODIC_EVT implementation in simple_peripheral example of BLE stack.
Thank you for your reply, can you explain about Tasksleep(1000) --> how many seconds this
You can use "Task_sleep(standbyDurationUs / Clock_tickPeriod)" and standbyDurationUs is the time you intend to delay in us.
Thank you for reply,For me this code working
while(!PIN_getInputValue(pinId)) {
PIN_setOutputValue(ledPinHandle, Board_LED1, 1);
CPUdelay(8000*50);
PIN_setOutputValue(ledPinHandle, Board_LED1, 0);
CPUdelay(8000*50);
}
But when trying to replay CPUdelay as Tasksleep it is not working why can please explain about this please
while(!PIN_getInputValue(pinId)) {
uint32_t sleepUs = 50000000;
PIN_setOutputValue(ledPinHandle, Board_LED1, 1);
Task_sleep(sleepUs / Clock_tickPeriod);
PIN_setOutputValue(ledPinHandle, Board_LED1, 0);
Task_sleep(sleepUs / Clock_tickPeriod);
}
When you set sleepUs = 50000000, it will sleep 50 seconds and it's too long for led blinking. You can try to use sleepUs = 500000 to see if LED can blink in 500 ms interval.
Hi Yikai,
It is working now, but I have one doubt how you are saying 50000000 -> 50 s and 500000 -> 500 ms. can you so your calculation
I had replied you that standbyDurationUs is the time you intend to delay in us, so 50000000us is equal to 50000ms and 50000ms is equal to 50 seconds.
Thank you so much for the reply, finally, I got some idea
Clock_tickPeriod -> oxa(Hexa) -> 10(decimal)
Task_sleep(sleepUs / Clock_tickPeriod); -> Task_sleep(50000/10) -> 0.005 seconds
this calculation is correct can you please explain