Page 1 of 1

Task management - Keeping a led on constantly

Posted: Tue Apr 23, 2019 1:39 pm
by nesicarh
Hey everyone,

This is a relatively simple one, but i couldn't find a thread about it. So I'm still getting to know the FreeRTOS abstractions, and I was wondering what I was doing wrong.

Imagine a situation where you wanted to connect to WiFi. Until the connection is established, the onboard led should blink. When the handshake is successfully completed, the led should be always on. However, If i do not manually relinquish control from the task, it will starve the watchdog process and it will not behave in the way i expect it to do. The best I could come up with is to call vTaskDelay() for about 20 milis so i can get the control back to the scheduler, but during this time, the led powers down, so i have a perceptible blink. Is it possible to somehow do "background" tasks, and always keep them active, such as powering a motor, or an LED or a pump whatever, while simultaneously checking for temperature or humidity in regular intervals?

Re: Task management - Keeping a led on constantly

Posted: Wed Apr 24, 2019 5:18 am
by ESP_Sprite
You are aware that a GPIO normally keeps its state, as in the normal behaviour is that it stays on once you've set it to be on?

Re: Task management - Keeping a led on constantly

Posted: Fri Apr 26, 2019 3:30 pm
by nesicarh
I was not aware of that tnx :)

Re: Task management - Keeping a led on constantly

Posted: Fri Apr 26, 2019 3:31 pm
by nesicarh
I'll reasearch it more, but I think it resets the state when i delay or suspend the task.

Re: Task management - Keeping a led on constantly

Posted: Sat Apr 27, 2019 12:59 am
by fly135
nesicarh wrote:
Fri Apr 26, 2019 3:31 pm
I'll reasearch it more, but I think it resets the state when i delay or suspend the task.
That would not be normal behavior. Calling delay should not affect the state of a GPIO.

John A

Re: Task management - Keeping a led on constantly

Posted: Sat Apr 27, 2019 7:16 pm
by Ritesh
nesicarh wrote:
Tue Apr 23, 2019 1:39 pm
Hey everyone,

This is a relatively simple one, but i couldn't find a thread about it. So I'm still getting to know the FreeRTOS abstractions, and I was wondering what I was doing wrong.

Imagine a situation where you wanted to connect to WiFi. Until the connection is established, the onboard led should blink. When the handshake is successfully completed, the led should be always on. However, If i do not manually relinquish control from the task, it will starve the watchdog process and it will not behave in the way i expect it to do. The best I could come up with is to call vTaskDelay() for about 20 milis so i can get the control back to the scheduler, but during this time, the led powers down, so i have a perceptible blink. Is it possible to somehow do "background" tasks, and always keep them active, such as powering a motor, or an LED or a pump whatever, while simultaneously checking for temperature or humidity in regular intervals?
You can do one thing like create task initially while starting firmware in which blink LED state as per your requirement and then delete task once you get connectivity. Also change LED state to high as per your requirement.

And once you get disconnect event then again start that LED blink task.

So, I think using that way also you can control LED as per your requirement.