''***************************** ''* VarWatch Demo v1.0 * ''***************************** ' Demonstrates the BgWatch object, that allows to watch the values ' of predefined variables at runtime. CON _clkmode = xtal1 + pll16x _xinfreq = 5_000_000 VAR long inp long tstl word tstw byte tstb byte keyc byte arrb[14] OBJ dbg : "BgWatch" kb : "pc_keyboard" PUB main | i ' define the object dbg, and ' add only this short code at start to watch vars '------------------------------------------------ 'start the watcher (uses 1 cog) dbg.start(30) '(pin 30 for TX) 'define the variables to watch dbg.watch_var(2,@tstl,string("L Counter"),1) 'for parameters see BgWatch dbg.watch_var(3,@keyc,string("B$Keyc"),1) dbg.watch_var(4,@tstw,string("W$Calc"),1) dbg.watch_var(5,@tstb,string("B Index"),1) dbg.watch_var(6,@arrb,string("B'Array["),8) dbg.watch_var(7,@arrb,string("B$Array["),8) dbg.watch_var(9, $1EF, string("S Frq P2"), 1) 'shows the FreqCounter dbg.count_freq(2, 1) 'set FreqCounter at Pin 2 dbg.wiggle_pin(2, 10_000) 'set Pin wiggler with 10kHz at Pin2 '------------------------------------------------ ' here follows your normal code ' the watcher runs in background, you have nothing ' to change or insert to watch the selected variables 'start the keyboard kb.start(26, 27) dira[0]~~ 'change the variables tstb := 0 repeat waitcnt(clkfreq/5 + cnt) tstl++ if kb.gotkey keyc := kb.key arrb[tstb++] := keyc tstb &= 7 tstw := tstl>>4 + keyc !outa[0]