Aries
New Member
Another oddity with the 40X2 - it seems that the TUNE command does something to the internal clock frequency.
This code tests a piezo sounder by playing a (rather off) sequence of octaves, printing out the counter and the tune-code frequency. Without a PAUSE (or with PAUSE 0) after the TUNE command, the next sertxd is garbled for the first argument, and then reverts. PAUSE for any longer time works correctly. This only happens at em64. It's not a problem as long as one knows, but it is annoying.
and the results:
This code tests a piezo sounder by playing a (rather off) sequence of octaves, printing out the counter and the tune-code frequency. Without a PAUSE (or with PAUSE 0) after the TUNE command, the next sertxd is garbled for the first argument, and then reverts. PAUSE for any longer time works correctly. This only happens at em64. It's not a problem as long as one knows, but it is annoying.
Code:
#picaxe 40x2
#no_data
#no_table
symbol SoundPin = D.0
symbol RingTone = 0
#terminal 76800
setfreq em64
pause 8000
ptr = RingTone
for b0 = 0 to 255
lookup b0,(3,$E0,$E2,$E4,$E5,$E7,$E9,$EB,$C0,$C2,$C4,$C5,$C7,$C9,$CB,$D0,$D2,$D4,$D5,$D7,$D9,$DB,$FF),b1
@ptrinc = b1
if b1 = $FF then exit
next b0
b3 = 0
main:
b0 = RingTone
b3 = 1 - b3
get b0,b1 ' tempo
for b21 = 0 to 63
sertxd(13,10,#b0)
b0 = b0 + 1
get b0,b2 ' next note
if b2 = $FF then EndRing
sertxd(" ... ",#b0," ",#b2," (",#b3,")")
tune SoundPin,b1,(b2)
pause b3
sertxd(" .. ",#b0)
next b21
EndRing:
pause 1000
goto main
Code:
...
16 ... 17 212 (1) .. 17
17 ... 18 213 (1) .. 18
18 ... 19 215 (1) .. 19
19 ... 20 217 (1) .. 20
20 ... 21 219 (1) .. 21
21
0 ... 1 224 (0)[00][9E]y[97] 1
1 ... 2 226 (0)[00][9E]y[97] 2
2 ... 3 228 (0)[00][9E]y[97] 3
...