A practical walkthrough of implementing a multiplexed 7-segment display driver in Ada on the STM32F407 Discovery board. Covers Ada-specific idioms including protected objects for ISR attachment, packed boolean arrays for GPIO bit manipulation, and unchecked conversions. Demonstrates Timer 6 setup for 2.5ms multiplexing interrupts and explains the ARR/CNT race condition when shrinking timer reload values while the timer is running. A key highlight is Ada's runtime range checking: the author intentionally triggers a Constraint Error to demonstrate the last-chance handler, but also accidentally discovers a real overflow bug where update rates below 4/sec produce values exceeding the 16-bit ARR register capacity — something C would silently corrupt. The fix involves adjusting the prescaler from 1µs to 5µs to keep ARR values within range.

19m read timeFrom embeddedrelated.com
Post cover image
Table of contents
7 Segments the Ada WaySome DetailsGotcha!Second Things First!Busted By My Own Code!So What?
34 Impressions