embedded-trainings-2020/embedded-workshop-book/src/time.md

16 lines
1.2 KiB
Markdown
Raw Normal View History

2020-07-08 13:06:49 +00:00
# Timers and Time
Next we'll look into the time related APIs exposed by the `dk` HAL.
2020-07-14 11:51:11 +00:00
✅ Open the `src/bin/blinky.rs` file.
2020-07-08 13:06:49 +00:00
This program will blink (turn on and off) one of the LEDs on the board. The time interval between each toggle operation is one second. This wait time between consecutive operations is generated by the blocking `timer.wait` operation. This function call will block the program execution for the specified [`Duration`] argument.
[`Duration`]: https://doc.rust-lang.org/core/time/struct.Duration.html
The other time related API exposed by the `dk` HAL is the `dk::uptime` function. This function returns the time that has elapsed since the call to the `dk::init` function. This function is used in the program to log the time of each LED toggle operation.
2020-07-15 16:01:00 +00:00
✅ Try changing the `Duration` value passed to `Timer.wait`. Try values larger than one second and smaller than one second. What values of `Duration` make the blinking imperceptible?
2021-04-08 09:27:00 +00:00
❗If you set the duration to below 2ms, try removing the `defmt::info!` command in the loop. Too much logging will fill the logging buffer and cause the loop to slow down, resulting in the blink frequency to reduce after a while.