From: Sébastien L. <sq...@gm...> - 2010-07-19 15:11:02
|
hi, i'm playing with interrupts in pic18. in main.c I have: ------------------------------------------------ #include <signal.h> SIGHANDLER(i2c_slave_isr); //forward declaration, implementation is elsewhere DEF_INTHIGH(high_int) DEF_HANDLER(SIG_SSP, i2c_slave_isr); END_DEF ------------------------------------------------ in i2c_slave.c, I have: ------------------------------------------------ #include <signal.h> SIGHANDLER(i2c_slave_isr) { ...... } ------------------------------------------------ main.c cannot compile. although there is a function prototype for i2c_slave_isr, this function is not called by any C code and SDCC does not include an "extern _i2c_slave_isr" line in the asm file, so the function is not declared and the file cannot be compiled. However iIf I add a ------------------------------------------------ void never_called() { i2c_slave_isr(); } ------------------------------------------------ somewhere in main.c, this file compiles. But then I suck two more flash words with a useless: ------------------------------------------------ ; ; Starting pCode block S_main__never_called code _never_called: ; .line 89; main.c i2c_slave_isr(); CALL _i2c_slave_isr RETURN ------------------------------------------------ but this is the code that actually enables the "extern" line ! Is there an __attribute__((used)) thing I can use so that the extern gets generated and I can avoid the never_used routine? this could be added in a DECLARE_SIGHANDLER(name) macro. I tried adding a ------------------------------------------------ __asm extern _i2c_slave_isr __endasm; ------------------------------------------------ before DEF_INTHIGH, but that does not help. I get an error: main.c:84: syntax error: token -> '__endasm' ; column 13 Regards Sebastien |