mhyem2
July 21, 2020, 2:10pm
1
I saw some one use variable name "SP" to print stack pointer.
like
Serial.print(SP)
and when I tried to use it,
I met error message
"SP was not declared in this scope".
I did not use it in any other function, but just in setup() or loop() function.
What did I wrong?
Thank you
mhyem2
July 21, 2020, 2:27pm
3
spycatcher2k:
Post your FULL code, as it looks like you did not declare SP.
Yes, I did not declared SP.
What I am confused is,
as far as I know,
SP is reserved symbol for stack pointer.
so I did not need to declare.
SP was not declared should not come out as an error message, because it is already declared in other library file in arduino IDE.
mhyem2:
...because it is already declared in other library file in arduino IDE.
If that were true, you would not be getting the error....
Regards,
Ray L.
SP is defined on AVR boards, not necessarily on others.
Which board are you using?
mhyem2
July 21, 2020, 3:05pm
7
oqibidipo:
SP is defined on AVR boards, not necessarily on others.
Which board are you using?
I am using Arduino Nano 33 BLE
Thank you,
then, is there any way to get stack pointer? like AVR boards?
What do you need it for? There may be an easy work-around.
MarkT
July 21, 2020, 3:22pm
9
If you do need to reference a machine register, use asm()...
mhyem2
July 21, 2020, 3:23pm
10
aarg:
What do you need it for? There may be an easy work-around.
I just want to check stack pointers after function calls..
Thank you for all replies
mhyem2
July 21, 2020, 3:34pm
12
aarg:
Yes, but why?
To check stack region in SRAM of ARM cortex M4 which is a CPU of Arduino Nano 33 BLE?
I thought there must be a reserved region in SRAM for like function prarmeter and return address after procedure call except data and variables. and want to check that region.
Yeah, I don't mean to be a pest, but you have again avoided the main question, which is why you want to check that region?