4.6.17 PIC16 Port - Tips

Next: 4.6.18 Known Bugs Up: 4.6 The PIC16 port Previous: 4.6.16 PIC16 C Libraries Contents Index
Subsections

- 4.6.17.1 Stack size

## 4.6.17 PIC16 Port - Tips

Here you can find some general tips for compiling programs with SDCC/pic16.

### 4.6.17.1 Stack size

The default stack size (that is 64 bytes) probably is enough for many programs. One must take care that when there are many levels of function nesting, or there is excessive usage of stack, its size should be extended. An example of such a case is the printf/sprintf family of functions. If you encounter problems like not being able to print integers, then you need to set the stack size around the maximum (256 for small stack model). The following diagram shows what happens when calling printf to print an integer:

  printf () -> ltoa () -> ultoa () -> divschar ()

It is should be understood that stack is easily consumed when calling complicated functions. Using command line arguments like --fommit-frame-pointer might reduce stack usage by not creating unnecessery stack frames. Other ways to reduce stack usage may exist.