??? 12/06/04 13:52 Read: times |
#82600 - an idea... Responding to: ???'s previous message |
In cases where I need the same routine at int as well as main level, I usually write most of it as a macro to save the bugmaker of "change needed in two places" I've not tried this, but I wonder if putting the shared function (and the shared function alone) into a file that is #inlcuded with the ISR and main would help? Making the function static should avoid name clashes - and the ISR and main would have to be in separate files; something like: shared.c static void shared_fn( void ) { // your code here } isr.c #include shared.c // Creates a *local* function void isr( void ) interrupt x using y { // your ISR code here shared_fn(); // Calls *local* function // more ISR code here } main.c #include shared.c // Creates a *local* function void main( void ) { // your main code here shared_fn(); // Calls *local* function // more main code here } Thus both main.c and isr.c have a "local" function called "shared_fn" - they are completely distinct, so no MULTIPLE CALL TO SEGMENT problems, and you avoid risking the Gotchas! of 'C' macros. Downside is, of course, increased code size. |
Topic | Author | Date |
89s52 function sharing. | 01/01/70 00:00 | |
Try This | 01/01/70 00:00 | |
emphasis | 01/01/70 00:00 | |
an idea... | 01/01/70 00:00 | |
Andy, I tried it | 01/01/70 00:00 | |
Jolly good! | 01/01/70 00:00 | |
Error | 01/01/70 00:00 | |
You need to work on it | 01/01/70 00:00 | |
reentrant ? | 01/01/70 00:00 | |
reentrant | 01/01/70 00:00 | |
non-reentrant | 01/01/70 00:00 | |
Wow | 01/01/70 00:00 | |
varaible sharing? | 01/01/70 00:00 | |
Variable sharing | 01/01/70 00:00 | |
Overflow | 01/01/70 00:00 | |
variables, main and ISR | 01/01/70 00:00 | |
Globals use more memory | 01/01/70 00:00 | |
Isn't that a global? | 01/01/70 00:00 | |
Globals, ISRs, main, & static![]() | 01/01/70 00:00 |