In SX Microcontrollers, SX/B Compiler and SX-Key Tool, AmitJ wrote: I am trying to run a serin command with a timeout from within a subroutine. However if the timeout occurs I still want to return to the command after the subroutine call. An example of what I want to do is below. The problem is that the variable gled1 never gets cleared in normal run mode if the timeout occurs. However if I uncomment the break and run it in debug mode it works fine. I am checking the pin status using a good scope. From my understanding the timeout triggers a jmp to 'missed' so the original return address should still be at the top of the stack. The return in 'missed' or 'rs' should be accessing the same address, I think. If I replace the serin with 'goto missed' it also only works in debug mode. Anyone have any suggestions? Also is there any way to empty the call stack? Thanks a lot! Amit [code] DEVICE SX48, OSCHS2 FREQ 50_000_000 PROGRAM start GLED1 var RC.2 'LED RLED2 var RC.3 'LED missed sub 'signal missed comm rs sub 'receive serial comm start: temp = 0 output gled1 output rled2 goto mainloop rs: \clrb rled2 serin ra.0, T57600, temp, 1, missed 'goto missed return missed: \setb rled2 return MainLoop: \setb gled1 rs \clrb gled1 temp=6 ' watch temp ' break goto MainLoop [/code] ---------- End of Message ---------- You can view the post on-line at: http://forums.parallax.com/forums/default.aspx?f=7&p=1&m=147472 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)