Turn-key PCB assembly services in prototype quantities or low-volume to mid-volume production runs

Store constants and arrays in program memory

In many cases our embedded projects have to deal with various constants or arrays that aren’t changed during program execution. So why put them in RAM if we can store constant data in flash memory and leave RAM untouched. RAM is precious in micro-controllers so leave it for stack and heaps. For instance you are using an LCD in your project and want to send “Hello World” to it you simply grab one of common LCD libraries and use command like: LCDstring(“Hello World”); By using this innocent action we end up in storing this string in flash memory during compilation and loading it to RAM during program start-up routines in microcontroller. When LCDstring() command is executed string is read from SRAM not from FLASH. So we end up with two… Continue reading