Hi, [EMAIL PROTECTED] schrieb: > polling volatile variable TIMEOUT from main() is failed.
does it wait forever or does it continue to soon or does it continue irregularly? > volatile unsigned int TICKS; // system ticks > volatile unsigned char TIMEOUT; // system timeout flag > ===== > SYS.C > ===== > #include <at89x52.h> > #include "sys.h" > > void SystemTick( void ) interrupt 1 using 1 { > TR0 = 0; > TL0 = (unsigned char) RELOAD_VALUE; > TH0 = (unsigned char) ((unsigned int) RELOAD_VALUE >> 8); > TR0 = 1; > > /* system ticks */ > if ( TICKS ) { > TICKS--; > return; > } > TIMEOUT = 1; > } > > void LoadDelay( unsigned int ticks ) { > if ( ticks ) { > TIMEOUT = 0; > TICKS = ticks; > } > } you would need to protect access to TICKS so the IRQ doesn't interfere. Also TIMEOUT might be set by the IRQ when you won't expect it. (bit EA_SAVE=EA; EA=0; ....) Is the IRQ called? Maybe also toggle a LED there. Like P1_7 = (counter++ & 0x80); Two other notes: "using 1" or "__using(1)" is not needed (you do not use r0..r7 in the IRQ). Surprisingly often using "using" gives very little benefit and just eats data memory. volatile unsigned char TIMEOUT; you could/should use a bit variable there "volatile bit TIMEOUT" Greetings, Frieder ------------------------------------------------------------------------- Take Surveys. Earn Cash. Influence the Future of IT Join SourceForge.net's Techsay panel and you'll get the chance to share your opinions on IT & business topics through brief surveys -- and earn cash http://www.techsay.com/default.php?page=join.php&p=sourceforge&CID=DEVDEV _______________________________________________ Sdcc-user mailing list Sdcc-user@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/sdcc-user