Assert on a Microcontroller | Embedded System Project Series #14

preview_player
Показать описание
I create an assert implementation for my microcontroller. It stops the motors, logs to a terminal, triggers a breakpoint, and blinks an LED.

0:00 Assert
1:00 This video
1:20 My implementation
2:26 Custom assert function
3:53 Software breakpoint
4:55 With TI compiler
6:05 With GCC compiler
7:08 Add breakpoint to assert function
9:05 LED driver
11:27 Two new IO functions
13:47 Test the LED driver
14:35 Test asserts
15:37 Recursive assert problem!
17:09 Busy wait macro
18:05 Commit 1
19:00 Static assert
20:55 Commit 2
21:30 Replace todos (I forgot!)
22:20 Last words

#embeddedsystems #cprogramming #electronics

🌍 Useful links

⌨️ My development environment

🌍 Links

👨‍💻 About me
Hi and welcome. I'm Niklas, an embedded systems engineer from Sweden. On this channel, I make practical videos about embedded systems or, in general terms, about building and programming hardware.
Рекомендации по теме
Комментарии
Автор

Bro even if your videos are a bit niche, they are very useful for us (new engineers).
I have been watching your videos for months since I'm actually doing the same thing on a different microcontroller.
I hope to see you again, one day, with a new crazy video series.
Thank you very much ❤.

abdoullatifabdoumoussa
Автор

First of all:
Great content! You definitely deserve wayyy more subs :)

Second:
This is very similar to what we do in my industry (safety-critical systems). We typically call the macro either ASSERT or FUSE. They must always be present on the release code as well. We use them to add defensive programming everywhere. For example, we use them to always check all function parameters. This has of course a huge impact on performance (we have thousands of asserts) but this another story... Typically we do something very similar to what you presented here. When the assert handler is called, we first send the error to our non-safe system, which is the one doing all the logging. Then we just enter an infinite loop in which we are de-energizing all of our system's outputs (that is our safe state).

varez