In SX Microcontrollers, SX/B Compiler and SX-Key Tool, g_daubach wrote: Chet, to be honest, I'm not really an SX/B expert. I took your sample code, and tried it with SXSim. I can confirm that the program seems to "hang" in some waiting state when you activate RB.0 for a longer time. I then had a look at the assembly code SX/B generated from your source. The line at label ISR_Start: WKPEND_B = WhichOne is translated into MODE $09 MOV !RB,WhichOne MOV WhichOne, w actually, the MOV !RB,WhichOne is a compound statement, so this is the code the SX "sees": MODE $09 MOV w,WhichOne MOV !RB, w MOV WhichOne, w Now comes the "tricky" part: The MOV !RB, w is not really a move operation but an exchange operation instead. IOW, after this instruction, w holds the former value of !RB (the WKPND_B bits), and the WKPND_B register contains the former value of w. In this code, WKPND_B will be left with the contents of WhichOne. After the first interrupt, WhichOne contains 1 which is swapped into WKPND_B thus causing another imterrupt immediately after the RETURNINT is executed. This is what makes you think the program is "hanging" somehow. Actually, it is handlinginterrupts all the time. Look at SXSim's Interrupt Cycles display, to confirm that. How can this be fixed? In assembly, I simply would insert a CLR w before the MOV !RB,w instruction. In SX/B, the compiler should do it automatically! Rocklin: We have a problem !!! At least, I'm happy that this is not an SXSim bug but that I could use SXSim to find it - thanks for the appause :-) . ---------- End of Message ---------- You can view the post on-line at: http://forums.parallax.com/forums/default.aspx?f=7&p=1&m=105223#m105287 Need assistance? Send an email to the Forum Administrator at forumadmin@parallax.com The Parallax Forums are powered by dotNetBB Forums, copyright 2002-2006 (http://www.dotNetBB.com)