'*** 20x2 running diagnostic to test
'*** using "setfreq" in subroutines.
symbol LED=B.2 'pin 16 green wire
#Picaxe 20x2
setfreq M4
main:
do
setfreq M4
pause 2000
call set8
call set16
call set32
call set64
loop
set8:
setfreq M8
toggle led
pause 500
toggle led
pause 500
toggle led
pause 500
toggle led
setfreq M4
pause 1000
return
set16:
setfreq M16
toggle led
pause 500
toggle led
pause 500
toggle led
pause 500
toggle led
setfreq M4
pause 1000
return
set32:
setfreq M32
toggle led
pause 500
toggle led
pause 500
toggle led
pause 500
toggle led
setfreq M4
pause 1000
return
set64:
setfreq M64
toggle led
pause 500
toggle led
pause 500
toggle led
pause 500
toggle led
return
Main:
gosub flash4
pause 2000
gosub flash8
pause 4000
goto main
flash4:
setfreq M4
for b0 = 1 to 5
high LED
pause 500
low LED
pause 500
next b0
flash8:
setfreq M8
for b0 = 1 to 5
high LED
pause 500
low LED
pause 500
next b0
Thanks; srnet...I'll try it. Sure is much simpler. JimsWell for one, the program is downloaded as a whole, and then executed, there is no concept of commands running before or during the program download.
The setfreq you have above, before Main:, is executed after download, when the program first runs.
try this;
Code:Main: gosub flash4 pause 2000 gosub flash8 pause 4000 goto main flash4: setfreq M4 for b0 = 1 to 5 high LED pause 500 low LED pause 500 next b0 flash8: setfreq M8 for b0 = 1 to 5 high LED pause 500 low LED pause 500 next b0
I put some returns at the end of each subroutine & works very well.Thanks; srnet...I'll try it. Sure is much simpler. Jims
I suspect that jims confusion comes about from “commands” such as DATA or EEPROM and TABLE which are PE directives and only acted upon at the time of program download. Most but not all PE directives have the hash (#) character which helps to distinguish from BASIC program commands.Well for one, the program is downloaded as a whole, and then executed, there is no concept of commands running before or during the program download.
The setfreq you have above, before Main:, is executed after download, when the program first runs.