Jeremy PWM

Dippy

Moderator
Jeremy,
Have a play with this on your scope:
Its for an 18X. Works on my scope OK.

Code:
' 4 second pauses so that scope can do F measurement
looper:
pwmout 3,150,200 ‘ set pwm
peek $12,b1
sertxd (""Normal: ",#b1,13,10)
pause 4000
b1 = b1 + 1			' add 1 (bin 1) for TMR2 prescale
poke $12, b1
peek $12,b1			' peek to confirm
sertxd ("Prescale / 4: ",#b1,13,10)
pause 4000 ‘ pause 1 s
b1 = b1 + 1			' add 1 (total 2 bin 10)for TMR2 prescale
poke $12, b1
peek $12,b1			' peek to confirm
sertxd ("Prescale / 16: ",#b1,13,10)
pause 4000 ‘ pause 1 s
b1=b1-2			' Back to normal (i.e. TMR2 prescale = 1)
poke $12, b1
goto looper ‘ loop back to start
I've only had a quick go so I don't know if it upsets other things. So may need a workaround in some cases.
 
Last edited by a moderator:

Jeremy Leach

Senior Member
Nice one Dippy !

Scope shows exactly as expected. /4 and /16 of the period set by pwmout. I've had a play and as the maths shows, lowest freq PWMout we can get using this is around 243Hz.

Another discovery which could be very useful. This xmas break has worked wonders <img src="wink.gif" width=15 height=15 align=middle>
 
Top