Another video in my video series is out. In this one, I implement an assert handler for my microcontroller. The typical behavior of an assert is to abort a program when a certain condition is not fulfilled, which is a reasonable thing to do on a system with an operating system. A bare-metal microcontroller has no operating system. There is only one program, and it's running bare, and as such, it doesn't make sense to abort this program in the same way. So if you want to take advantage of asserts on a microcontroller, you need to roll your own implementation, which is what I do in my video. I implement an assert that
- Stops the motors ("safe state")
- Logs the location of the assert
- Triggers a breakpoint
- Blinks an LED indefinitely
As always, the code is available in my GitHub repository.