Key Engineering Takeaways
- •Flash Memory is non-volatile ROM where your compiled C++ program code binary resides permanently.
- •SRAM (Static RAM) is volatile memory where global variables, dynamic buffers, and function call stacks are stored during execution.
- •EEPROM / NVS (Non-Volatile Storage) stores user settings (like Wi-Fi passwords and PID motor gains) that persist across reboots.
- •The Stack grows downward from high memory; the Heap grows upward from low memory. If they collide, a catastrophic Stack Overflow crash occurs.
- •In 32-bit microcontrollers, hardware pins and timers are controlled by reading and writing to specific 32-bit Memory-Mapped I/O addresses.
- • Pointers and variables in C/C++
- • Any microcontroller development board
The Three Primary Memory Types in Microcontrollers
Stack vs Heap: Anatomy of Embedded SRAM
Frequently Asked Questions
Why should I avoid malloc() and new in microcontroller programming?
On systems with tiny RAM, repeatedly allocating and freeing variable-sized memory blocks causes Heap Fragmentation. Over time, RAM becomes broken into tiny unusable gaps, causing future allocations to fail and crashing your robot.