Knowledgebase

Embedded Programming Practice Print

  • specialisedtechnology, specialised, performance, guide, howto, solution, zillionkinghost, hosting
  • 0

Writing firmware.

WHAT LANGUAGES DOMINATE

C, overwhelmingly C++, in larger systems Rust, increasingly, for memory safety Assembly, for specific routines

WHAT TO AVOID

Dynamic allocation after initialisation Recursion, where stack depth is unbounded Blocking operations in interrupt handlers Floating point, where the hardware lacks it

WHAT INTERRUPT HANDLERS MUST BE

Short, and non-blocking.

WHAT THEY SHOULD DO

Record what happened, and signal the main loop.

WHY

Long handlers delay other interrupts and cause missed events.

WHAT VOLATILE MEANS

A value that may change outside the program's control.

WHERE IT IS REQUIRED

Hardware registers, and variables shared with interrupt handlers.

WHAT HAPPENS WITHOUT IT

The compiler optimises away reads, and the program never sees changes.

WHAT A WATCHDOG TIMER DOES

Resets the system if not periodically reset by software.

WHY IT MATTERS

An unattended device that has hung must recover itself.

WHAT TO BE CAREFUL WITH

Resetting the watchdog in a place that continues running when the system is actually stuck.

WHAT TO TEST

Behaviour on power loss mid-operation.


Was this answer helpful?
Back

Are you happy with your experience? Leave us a review on Trustpilot.


Trustpilot