SDAA552 September 2026 MSPM0C1103 , MSPM0C1103-Q1 , MSPM0C1104 , MSPM0C1104-Q1
Functions can make code much easier to read. However, functions can also add overhead in terms of execution speed and code space. If a function is only called once, especially for small functions, the extra overhead is typically not worth it. You can keep a small function for readability but not incur the extra overhead by inlining the function using the inline (or __inline) keyword with the function declaration. This declaration instructs the compiler to insert the contents of the function everywhere the function is called, instead of performing an actual function call.
However, there are also cases where something needs to be done several times in the code. In this case, a function can make for a more code-size efficient solution, because it allows the same code to be reused in several different places. Writing code intentionally for reusability can make a big difference on code size as well.