In embedded systems, timers offer the ability to delay a call to a function, periodically call a function, or control some peripheral without the need for CPU intervention. In FreeRTOS, a software timer is controlled by a timer service task and can be used to execute a function some time in the future based on the RTOS tick timer.
The solution to the challenge in the video can be found here:
https://www.digikey.com/en/maker/projects/introduction-to-rtos-solution-to-part-8-software-timers/0f64cf758da440a29476165a5b2e577e Code for this video series (including demonstrations, challenges, and solutions) can be found here:
https://github.com/ShawnHymel/introduction-to-rtos FreeRTOS gives us a software timer library that we can use to configure several timers. These timers are tied to the tick timer, so we cannot get a resolution greater than the tick timer’s resolution (1 ms by default in the ESP32 Arduino package).
When we include the timer library, it will automatically spawn a timer service (or “daemon”) task that runs at priority 1 (default in ESP32 Arduino package). This service task is in charge of managing all of the software timers that are set.
Timers can count up or down and can be set to “one-shot” or “auto-reload.” Whenever a counter reaches its maximum value (as set in code), it will execute the callback function associated with that timer. A “one-shot” timer will execute the callback function only once, unless the timer is told to start counting again. An “auto-reload” timer will execute the callback function periodically at a rate specified by the timer’s max value.
In the video, we demonstrate the use of software timers and explain how they function within FreeRTOS. We also issue a challenge to create an auto-dimming LED feature whenever an interface is not being used.
Product Links:
https://www.digikey.com/en/products/detail/adafruit-industries-llc/3405/7244967 Related Videos:
Introduction to RTOS Part 1 - What is a Real-Time Operating System (RTOS)? -
https://youtu.be/F321087yYy4Introduction to RTOS Part 2 - Getting Started with FreeRTOS -
https://youtu.be/JIr7Xm_riRsIntroduction to RTOS Part 3 - Task Scheduling -
https://youtu.be/95yUbClyf3EIntroduction to RTOS Part 4 - Memory Management -
https://youtu.be/Qske3yZRW5IIntroduction to RTOS Part 5 - Queue -
https://youtu.be/pHJ3lxOoWeIIntroduction to RTOS Part 6 - Mutex -
https://youtu.be/I55auRpbiTsIntroduction to RTOS Part 7 -
https://youtu.be/5JcMtbA9QEEIntroduction to RTOS Part 8 -
https://youtu.be/b1f1Iex0TsoIntroduction to RTOS Part 9 -
https://youtu.be/qsflCf6ahXUIntroduction to RTOS Part 10 -
https://youtu.be/hRsWi4HIENcIntroduction to RTOS Part 11 -
https://youtu.be/C2xKhxROmhAIntroduction to RTOS Part 12 -
https://youtu.be/LPSHUcH5aQcRelated Project Links:
https://www.digikey.com/en/maker/projects/introduction-to-rtos-solution-to-part-8-software-timers/0f64cf758da440a29476165a5b2e577e Related Articles:
https://www.digikey.com/en/maker/videos/shawn-hymel/getting-started-with-stm32-and-nucleo-part-3-how-to-run-multiple-threads-with-cmsis-rtos-interfaceLearn more:
Maker.io -
https://www.digikey.com/en/makerDigi-Key’s Blog – TheCircuit
https://www.digikey.com/en/blogConnect with Digi-Key on Facebook
https://www.facebook.com/digikey.electronics/And follow us on Twitter
https://twitter.com/digikey