PhilHornby
Senior Member
Probably not a combination that happens very often, but the following program demonstrates an unrequested RESET @ 31KHz, using the LOOKUP statement. I've only tested it on the 20X2. It works in the simulator, but not on the real chip.
My guess (FWIW), is that some timer or other is expiring before the LOOKUP statement completes.
Code:
[COLOR=navy]#picaxe [/COLOR][COLOR=black]20x2[/COLOR]
[COLOR=navy]#terminal 9600
#no_data[/COLOR]
[COLOR=green]; Demonstration of RESET @ low frequency
[/COLOR][COLOR=blue]pause [/COLOR][COLOR=navy]2000[/COLOR]
[COLOR=blue]do
sertxd (cr[/COLOR][COLOR=black],[/COLOR][COLOR=blue]lf[/COLOR][COLOR=black],[/COLOR][COLOR=red]"START"[/COLOR][COLOR=blue])
setfreq K31
[/COLOR][COLOR=green];
; Takes 1.7 seconds to execute!
;
[/COLOR][COLOR=blue]lookup [/COLOR][COLOR=purple]b0[/COLOR][COLOR=black],[/COLOR][COLOR=blue]([/COLOR][COLOR=red]"xxxxxxxxxxxxxxxxxxxx"[/COLOR][COLOR=black], _
[/COLOR][COLOR=red]"xxxxxxxxxxxxxxxxxxxx"[/COLOR][COLOR=black], _
[/COLOR][COLOR=red]"xxxx"[/COLOR][COLOR=blue])[/COLOR][COLOR=black],[/COLOR][COLOR=purple]b1 [/COLOR][COLOR=green];64 Bytes
[/COLOR][COLOR=blue]setfreq M8
sertxd (cr[/COLOR][COLOR=black],[/COLOR][COLOR=blue]lf[/COLOR][COLOR=black],[/COLOR][COLOR=red]"1st lookup done"[/COLOR][COLOR=blue])
setfreq K31
[/COLOR][COLOR=green];
; Some combination of frequency and size of lookup data,
; causes Picaxe to restart.
;
[/COLOR][COLOR=blue]lookup [/COLOR][COLOR=purple]b0[/COLOR][COLOR=black],[/COLOR][COLOR=blue]([/COLOR][COLOR=red]"xxxxxxxxxxxxxxxxxxxx"[/COLOR][COLOR=black], _
[/COLOR][COLOR=red]"xxxxxxxxxxxxxxxxxxxx"[/COLOR][COLOR=black], _
[/COLOR][COLOR=red]"xxxxxxxxxxxxxxxxxxxx"[/COLOR][COLOR=black], _
[/COLOR][COLOR=red]"xxxxX"[/COLOR][COLOR=blue])[/COLOR][COLOR=black],[/COLOR][COLOR=purple]b1 [/COLOR][COLOR=green];65 Bytes
;
; With parameters as shown, this is part of the program is never executed.
;
; It is, if either of the following parameters are changed :-
;
; Setfreq M31 -> Setfreq K500
; Final "X" removed from lookup data string (shorten string to 64bytes)
;
[/COLOR][COLOR=blue]setfreq M8
sertxd (cr[/COLOR][COLOR=black],[/COLOR][COLOR=blue]lf[/COLOR][COLOR=black],[/COLOR][COLOR=red]"NEVER REACHED"[/COLOR][COLOR=blue])
loop[/COLOR]
Attachments
-
989 bytes Views: 0
Last edited: