View Full Version : The Musical PWMPAL

04-15-2007, 03:41 AM
Seems to work great :)
Way less pops than 'freqout'

C maj scale:

SEROUT 0,6,["!PWMSS",240] ' initialize outputs
ck CON 3600 ' set key of scale
cl CON 48:dl CON 54:el CON 60:fl CON 64 ' set ratios of note
gl CON 72:al CON 80:bl CON 90:ch CON 96 ' frequencies in major scale
dr VAR byte:x VAR nib:fr VAR byte ' set variables
FOR x= 0 to 7 ' start scale
LOOKUP x,[cl,dl,el,fl,gl,al,bl,ch],fr ' find notes
dr=ck/fr ' calculate duration from frquency
SEROUT 0,6,["!PWMM1",dr,0,dr,0] ' play note
PAUSE 400 ' set time for each note
NEXT ' goto next note
SEROUT 0,6,["!PWMSS",0] ' turn off all channels