Task management - Keeping a led on constantly

nesicarh
Posts: 5
Joined: Wed Feb 13, 2019 3:16 pm

Task management - Keeping a led on constantly

Postby nesicarh » 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?

ESP_Sprite
Posts: 9730
Joined: Thu Nov 26, 2015 4:08 am

Re: Task management - Keeping a led on constantly

Postby ESP_Sprite » Wed Apr 24, 2019 5:18 am

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?

nesicarh
Posts: 5
Joined: Wed Feb 13, 2019 3:16 pm

Re: Task management - Keeping a led on constantly

Postby nesicarh » Fri Apr 26, 2019 3:30 pm

I was not aware of that tnx :)

nesicarh
Posts: 5
Joined: Wed Feb 13, 2019 3:16 pm

Re: Task management - Keeping a led on constantly

Postby nesicarh » 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.

User avatar
fly135
Posts: 606
Joined: Wed Jan 03, 2018 8:33 pm
Location: Orlando, FL

Re: Task management - Keeping a led on constantly

Postby fly135 » Sat Apr 27, 2019 12:59 am

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

Ritesh
Posts: 1383
Joined: Tue Sep 06, 2016 9:37 am
Location: India
Contact:

Re: Task management - Keeping a led on constantly

Postby Ritesh » Sat Apr 27, 2019 7:16 pm

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.
Regards,
Ritesh Prajapati

Who is online

Users browsing this forum: No registered users and 101 guests