Break point for debugging

geezer88

Senior Member
While trying to figure out if my code was bad, or the LCD module I was playing with was bad, I came up with this simple way to pause a program so I can measure outputs with a volt meter to see if I was getting what I expected.

All you need is one or two available IO pins. One will need to be able to use touch. The basic idea is to insert a "gosub Break" in your code where ever you want it to pause. Then, the Break routine sits in a loop looking for the touch to be activated. This will give you the opportunity to measure voltages on various pins to see that you are getting what you expected. When your measuring is done, simply touch the sensor and you are back to regular execution.

The simplest sensor I could come up with is a paper clip. I straightened out one leg of a paper clip. Then I covered the remaining part with insulating tape. The bent out leg is soldered into the circuit at an unused pin location.

If you want, an LED can be attached to another empty pin and used to verify the threshold value is appropriate. If you don't have two extra pins, leave off the LED and it's code portion.

Happy coding,
tom


Code Snippet:

Break:

do

touch c.0, b9 'paper clip on C.0

loop until b9 > 200 '200 worked on my 18M2 your mileage may vary

high c.2 'LED on C.2
pause 250 'keep on long enough to get finger off clip
low c.2 'turn off LED

return
 
Top