Hello, On Mon, May 11, 2009 at 10:56 PM, Raphael Neider <rnei...@web.de> wrote: > Dear Néstor, > >> your answer is very appreciated. I have refactored the code as you >> told, I put all the global variables in a header file, called >> "defs.h". I have also taken out all the calls to functions from the >> interrupt. Now, interrupt handler routine is a lot simpler. Just one >> thing: I haven't been able to disable the interrupt and save the stack >> with the code you gave me. Apparently, it should work, since I'm using >> a PIC 16F877, which seems to have 16 stack bytes. Am I missing >> something from your explanation? > > > What do you mean with you "haven't been able to disable interrupts and > save the stack" --- could you do either but not both, or none? How did > you find out that you did not succeed in performing the task?!?
I'm able to disable interrupts with GIE=0, but when I try to save the stack, the interrupt just hangs. Look at the commented out code. > > Do you get compile time errors? No, no. It compiles smoothly. > Run-time errors? Yes, it hangs when I enable the timer to trigger the interrupt. > What precisely are the symptoms/error indications? This application draws a countdown. Well, this countdown actually stops when I enable the timer to trigger the interrupt which *should* refresh the countdown onscreen. Look at the commented out code, which is causing this behaviour. I'm maybe doing something wrong. Thanks. > > > > To make stack saving a bit more efficient, this afternoon I tried > (something like) > > static void > Intr(void) __interrupt(0) > { > char int_status; > char int_stack[16]; > __data char *src; > __data char *dst; > unsigned char u; > > // disable interrupts (same as the macro) > int_status = INTCON & 0xC0; > INTCON &= 0x3F; // GIE = PIE = 0; > > // save pseudo stack > src = (__data char *)0x70; // &STK00 > dst = &int_stack[0]; > for (u = 0; u < 16; u++) > { > *dst++ = *src++; > } > > // handle timer interrupt > if (T0IF) > { > T0IF = 0; // re-arm for next interrupt > // --- more handler code --- > } > > end: > // restore stack > src = &int_stack[0]; > dst = (__data char *)0x70; // &STK00 > for (u = 0; u < 16; u++) > { > *dst++ = *src++; > } > > // restore/re-enable interrupts > INTCON |= int_status; // restore GIE and PIE > } > > ... and the .asm looks good (did not test on real hardware, though). > > No meddling with GIE/PIE or T0IF/T0IE should be required in the > interrupt handler iff INTCON is masked and restored as shown. > Of course, you will have to enable GIE/PIE and T0IE at some point > in your program to enter the interrupt handler, but this seems to > be done in the menu handling code (if I recall correctly). > > Rather puzzled, > Raphael > > ------------------------------------------------------------------------------ > The NEW KODAK i700 Series Scanners deliver under ANY circumstances! Your > production scanning environment may not be a perfect world - but thanks to > Kodak, there's a perfect scanner to get the job done! With the NEW KODAK i700 > Series Scanner you'll get full speed at 300 dpi even with all image > processing features enabled. http://p.sf.net/sfu/kodak-com > _______________________________________________ > Sdcc-user mailing list > Sdcc-user@lists.sourceforge.net > https://lists.sourceforge.net/lists/listinfo/sdcc-user > -- Ricardo L. Febrero ------------------------------------------------------------------------------ The NEW KODAK i700 Series Scanners deliver under ANY circumstances! Your production scanning environment may not be a perfect world - but thanks to Kodak, there's a perfect scanner to get the job done! With the NEW KODAK i700 Series Scanner you'll get full speed at 300 dpi even with all image processing features enabled. http://p.sf.net/sfu/kodak-com _______________________________________________ Sdcc-user mailing list Sdcc-user@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/sdcc-user