From: Lenny S. <St...@me...> - 2000-12-26 15:27:28
|
I had a similar problem with an AT89C4051...(20 pin, 4k flash part)... When i called a function that returned a value, it always seemed to return false. I discovered that the ISR would push all the R registers, and call the function, then pop them all back after the call was made. The problem was that the Return value was in R2 when the funciton call returned...and the POP's to restore the saved R regs would overwrite the value. I assumed it was a compiler bug, and haven't called a function that requires a return value. (Which is just a work around...) -Lenny ----- Original Message ----- From: "Muhammad Fahmy F." <m_f...@ho...> To: <sdc...@li...> Sent: Monday, December 25, 2000 1:44 AM Subject: [Sdcc-user] i can't use my ISR function... (still) > thanks Michael, > > i tried the "critical" option but STILL the respond is not as i expected. > i guess i call functions from inside function that is called by my ISR, and > i haven't make all the functions related to be "critical", or should i ? > > do you have any solution besides "critical" options ? > > maybe this will help you to picture the situation: > > 1. mcu AT89C51, code max: 4Kbytes > > 2. command line : SDCC --model-small --code-loc 0xc000 > :) i use my own evaluation board, it runs well before using > any interrupt routines > > 3. the code: > > ... > > code unsigned char *LOGO1 = "logo 1"; > code unsigned char *LOGO2 = "logo 2"; > code unsigned char *INCOMING = "incoming"; > volatile unsigned int DELAY; // Global delaytime > > ... > > void main(void) > { > init_mcu(); > > lcd_clear(); // clear display > lcd_puts(4, 0, LOGO1); // displays "logo 1" > lcd_puts(0, 1, LOGO2); // displays "logo 2" > > while (1); > } > > > void External0_ISR(void) interrupt 0 // lo-to-hi transition triggered > { > lcd_clear(); > lcd_puts(4, 0, INCOMING); // display "incoming" > while(!RD1); // detect if the pin that generates > // int_0 is still low > } > > > void Timer0_ISR(void) interrupt 1 > { > ET0 = 0; // Disable Timer0-interrupt > if ( DELAY > 0 ) DELAY--; // Timebase ticks for delay-routine > ET0 = 1; // Enable Timer0-interrupt > } > > > void delay(unsigned int timer_base) // using timer_0 interrupt > { > if ( timer_base == 0 ) return; > DELAY = timer_base; > while ( DELAY > 0 ) _asm nop _endasm; > } > > > void lcd_clear(void) // Display Clear > { > // unsigned char d = 0x01; > send_command(0x01); > delay(20); > #ifdef DATA_LENGTH_4 > send_command(0x10); > delay(20); > #endif > } > > > void lcd_puts(unsigned char X, // column position 0 - 15 > bit Y, // row position 0 - 1 > unsigned char *KAL) // string > { > lcd_gotoxy(X,Y); > while(*KAL) lcd_putch(*KAL++); > } > > > void send_command(unsigned char CMD) > { > IREG = CMD; // CMD is sent to xdata > delay(2); > } > > ... > > > 4. that's all, any help is appreciated. > > > regards, > fahmy > _________________________________________________________________________ > Get Your Private, Free E-mail from MSN Hotmail at http://www.hotmail.com. > > > _______________________________________________ > Sdcc-user mailing list > Sdc...@li... > http://lists.sourceforge.net/mailman/listinfo/sdcc-user |