In SX Microcontrollers, SX/B Compiler and SX-Key Tool, Matthias09 wrote: Hey Zoot, thank you very much! I appreciate your helpful support and the best thing: The Ping runs now!! :) So thanks a lot! I would have never found the error. However, I got a problem: the values the Ping returns are jumping up and down vastly (e.g. 10 cm distance in rawdata: 19, 59, 9, 36,...). Something must affect the counting of cycles in the interrupt (INC rawdata). So my question: in DEBUG mode, can I run also with 50mhz, when i defined it with the FREQ command? I know I then use the SX Key clock, and I thought that one can only run with max. 4Mhz (which would be too slow). I fear, that my interrupt is so long, that it needs sometimes all the clock cycles available between two interrupts just for itself and leaving no time to run the main loop. I calculated this way: SX runs at 50Mhz (hopefully also in DEBUG mode). One clock cycle then needs 1/50MHz = 20ns = 0.20us to run. My interrupt runs 100,000 per second or every 10us. Between two interrupts I hence can make 10us/20ns = 10000/20 = 500 clock cycles. Means after every 500 clock cycles, the interrupt occurs, runs, takes away some cycles for itself and leaves some cycles left for the main loop. Is this correct? Could it be that the interrupt *sometimes* uses all 500 cycles for itself so the main loop cannot go on and the end of the high signal of the PING is not detected immediately (i know that already GOTO needs 3 cycles to process)? Warmest Wishes, Matthias ---------- End of Message ---------- You can view the post on-line at: http://forums.parallax.com/forums/default.aspx?f=7&p=1&m=394074#m401254 Need assistance? Send an email to the Forum Administrator at forumadmin@parallax.com The Parallax Forums are powered by dotNetBB Forums, copyright 2002-2009 (http://www.dotNetBB.com)