#1465 Function parameters on pic 18f1220

closed-invalid
nobody
5
2013-05-25
2008-06-03
No

I'm using a pic 18f1220 and i have to make some functions with parameters but they don't work..
For example:

void foo(unsigned char c) {
PORTB = c;
}
main() {
...
foo(133);
...
}

don't work, i think the parameter variable c contains 0, but:

main() {
...
PORTB = 133;
...
}

works well..

Same problem with sdcc v 2.6 and sdcc 2.8.
I'm compiling with:
/usr/bin/sdcc/sdcc -mpic16 -p18f1220 -V --debug -Wl-omain.hex -Wl-m -Wl-ainhx32 main.c

Discussion

  • SeventhGuardian

    SeventhGuardian - 2008-06-03

    Logged In: YES
    user_id=1067152
    Originator: NO

    Please try the svn version.

    I had similar issues with a pic18f2685, where function arguments, local variables and vectors didn't work. I suspected the crt code was the problem, and forcing the use of crt0.o seemed to solve it.

    With the latest svn code the crt issues seem to be solved, so you could give it a try..

     
  • Raphael Neider

    Raphael Neider - 2008-06-03
    • milestone: --> non_bugs
    • status: open --> closed-invalid
     
  • Raphael Neider

    Raphael Neider - 2008-06-03

    Logged In: YES
    user_id=1115835
    Originator: NO

    Your software stack is by default located at 0x200..0x2FF, though the 18f1220 only implements memory locations 0x000..0x0FF and 0xF80..0xFFF. As parameters are passed on the stack, they get read as 0 from unimplemented memory...

    Use

    #pragma stack 0xC0 0x40

    in your main() source file to place a 0x40 (64) byte stack in 0xC0..0xFF.

    Regards,
    Raphael

     

Log in to post a comment.