Closed eswarkeshav2001 closed 2 years ago
[STALE_SET] This issue has been automatically marked as stale because it has not had recent activity. It will be closed in 14 days if no further activity occurs. Thank you for your contributions.
Hi, your post was very difficult to read and the code is confusing too. I tried to edit the post (not the code) to make it more readable - please check that I didn't change the meaning. I would suggest you edit the code:
Remove unused (commented) code.
Remove unnecessary curly brackets: '{' and '}'.
Instead of global variable use FreeRTOS queue to pass data between tasks
NEVER use an infinite loop in a task without any yielding or blocking calls - no other task will get to be executed!
bin_sem
and bin_sem2
are created twice in the setup()
function - remove one of the creation.
Let the FreeRTOS decide on which core the task will run - instead of xTaskCreatePinnedToCore
use xTaskCreate - this does the same as the previous function, only without core specification.
Please try these tips and if it doesn't fix your issue let me know and post the updated code.
Closing due no response.
Make your question, not a Statement, inclusive. Include all pertinent information: Why I am not able to write a typical Global variable from multiple tasks and Why the if loops continuously iterate in a Task when there is no other task to run.
What you are trying to do? I am trying to Sample an ADC and Send the values to the Mobile Using BLE. Here I have Used a Hardware timer to Sample ADC once the sampling is done I want to stop the timer to optimize efficiency and when there is input from the User Via Bluetooth connection the timer should start again and the ADC sample has to be sent again. Here I haven't Implemented my BLE receiving part So well, but Used a global variable to simulate it.
Describe your system( Hardware, computer, O/S, core version, environment). Processor :Intel i5 Windows :10 Ide: arduino
Describe what is failing. When the Global variable is set by the BLE task(Task2) the Timer_turn on task (Task3 has to run). But it didn't work when I used GLOBAL variable t3 to act as a flag it didn't start the Timer_turn on task(task 3) didn't run. So I Used the actual Flag this time Timer_Turnon task in only running rest of the tasks is not running. It feels like the if condition at timer turn on task is running continuously without giving proper timer for other tasks. And then I Used Semaphore to signal the Timerturon once BLE task has completed ts work it works perfectly. But I still want to know why Flag method is going crazy and Global variable method is not working. I used freertos here. Please help me out, guys. Without knowing the answer I am not even able to sleep.
Show the shortest possible code that will duplicate the error.
Show the EXACT error message(it doesn't work is not enough). Global Variable
There is Error Message. It just works one time it doesn't work the other time. That means I'm unable to share the global variable
When using flag it works promisingly and printing a single statement timer started and it doesn't give enough time for other tasks even though all the tasks are same priority level
All of this work on your part shows us that you have worked to solve YOUR problem. The more complete your issue posting is, the more likely someone will volunteer their time to help you.
If you have a Guru Meditation Error or Backtrace, **please decode it:** I don't have Backtrace or Guru Meditation Error
Hardware:
Board: ESP32 Dev Module IDE name: Arduino IDE Flash Frequency: 80Mhz Upload Speed: 115200 Computer OS: Windows 10
Description:
Describe your problem here I am trying to Sample an ADC and Send the values to the Mobile Using BLE. Here I have Used a Hardware timer to Sample ADC once the sampling is done I want to stop the timer to optimize efficiency and when there is input from the User Via Bluetooth connection the timer should start again and the ADC sample has to be sent again. Here I haven't Implemented my BLE receiving part So well, but Used a global variable to simulate it. When the Global variable is set by the BLE task(Task2) the Timer_turn on task (Task3 has to run). But it didn't work when I used GLOBAL variable t3 to act as a flag it didn't start the Timer_turn on task(task 3) didn't run. So I Used the actual Flag this time Timer_Turnon task in only running rest of the tasks is not running. It feels like the if condition at timer turn on task is running continuously without giving proper timer for other tasks. And then I Used Semaphore to signal the Timerturon once BLE task has completed ts work it works perfectly. But I still want to know why Flag method is going crazy and Global variable method is not working. I used freertos here. Please help me out, guys. Without knowing the answer I am not even able to sleep.
Sketch: (leave the backquotes for code formatting)
Debug Messages:
Enable Core debug level: Debug on tools menu of Arduino IDE, then put the serial output here