I'm trying to make an multithreading kernel for atmega328p micro an for that i need to know how the stack pointer it works.
Most probably, your functions are rightly being inlined, so everything actually gets done straight in setup()
, with no function calls involved. If you want to forcefully disable inlining for them (to see the stack pointer change), you can apply the gcc noinline
attribute.
void __attribute__ ((noinline)) func1() {
...
}
If this still doesn't work, it's possible that gcc is applying tail call optimization anyhow. In that case, a simple method to make your functions not prone to this optimization is to print SP
both before and after the call.