Quantcast
Channel: MSP low-power microcontrollers
Viewing all articles
Browse latest Browse all 62309

Forum Post: RE: How to reduce the size of app code and bootloader

$
0
0
According to me experience, here are some suggestions for you: (0) Look at the memory map file (*.map) to check which section takes too much size. (1) Use simplified printf() or don't use it at all. (2) Use subroutine for code snippet appears twice. Limit the usage of INLINE. INLINE will increase code size. (3) Use "const" for data which don't need to be modified in run-time. For example, if you define a global variable "int xx[100] = {1, 2, 3... };" and use it somewhere the compiler don't know if it will be modified then the compiler will create the const data in flash and then copy them to SRAM in run-time. In the contrast, if the initialized values are not important or can be generated by formula then don't define its initialized values. This will reduce the usage of flash. (4) Carefully optimise the FRAM size used as heap memory. (5) and others... The most important part could be the structure of your firmware. A good structure will reduce code size massively. For example, recently I have a project using FR6820. FR6820 has only 32KB FRAM and the final code size is 30.1KB. You may think it is a simple project but it isn't. FR6820 has builtin LCD controller. It has to display various information on LCD, get 6 key inputs and operate in 7 modes with different functions. The secrete of a good structure is "event-driven + OOP" design methodology. If you use "main_loop + interrupt" to design the program then you have to put everything in the main-loop. It makes things complicated and difficult to maintain. But with RTOS, the whole system can be divided into several "tasks". Each task can run in its own event loop. TI has provided RTOS for MSP430. You can use it to simplify the software structure. For me, I also use C++ together with my RTOS. So, each task is also an "object" now. OOP (Object-Oriented Programming) can further simplify the software structure. OK, C++ may be too far away for you to try.

Viewing all articles
Browse latest Browse all 62309

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>