I've been chasing an obscure bug which I can't seem to reproduce on other hardware.
This program here will pop out messages to the serial terminal at 38000 baud. I never get more than about 10 seconds in before the Scope crashes.
Code:CON _clkmode = xtal1 + pll16x _xinfreq = 6_250_000 OBJ Term : "FullDuplexSerial" PUB Start | X, Y X~ Term.Start(31,30,0,38400) Y := cognew(@fred, 0) repeat term.str(String("survived ")) term.dec(X++) term.str(string(" loops",13)) waitcnt(cnt+clkfreq) DAT org 0 fred mov da, #$40 shl da, #24 mov frqb, da ' Set output freq mov ctrb, ctrb_mode ' Enable counter mov dira, ctrb_mask ' Enable outputs mov outa, pin ' set pin 27 high mov da, cnt add da, frq waitcnt da, frq ' wait a second mov dira, #0 ' Here is where it will crash waitcnt da, frq ' If it didn't crash this time, go around until it does. jmp #fred ctrb_mode long %00101 << 26 + 26 ctrb_mask long 1<<26 | 1<<27 frq long 80_000_000 pin long 1<<27 da res 1
The bit that is causing the crash is clearing dira while ctrb is still running at full tilt toggling the CLK net. I can't reproduce it on any other combination of pins, and if I disable the counter first (clear ctrb) then it does not happen.
It appears that this is the only way I can reproduce it.
pin 26&27 outputs
pin 27 high
counter toggling pin 26 faster than 6MHz
Now clear dira and it will crash hard but only intermittently.
The code I posted above is guaranteed to crash on my PropScope within 10 seconds.
"Are you suggesting coconuts migrate?"