radiogareth
Senior Member
I have a 14M2 running 8 LEDs on ports b.0-5 and C.0,C.1. ADC c.4 fed with a potentiometer.
I have all three PWM channels doing what I want, ie dimming the LEDs and I'm trying to get the best control/dimming capability out of the other 5 channels.
My understanding is that the PWM command uses an internal module and once set up, "does not get in the way of other code (much)", whereas pulsout deals with each pin I have allocated in turn. I THINK the highest duty cycle for the pulsout will be 20%, (5 pins running the command|) plus a bit of readadc time. The 14M2 is going flatout at 32Mhz and the flicker can't be seen, but of course, each LED is only coming up to a 1/5th of its capability (apart from the PW ones).
I think I'm asking a bit much of the poor little 14M2 and would perhaps be better just switching on/off the 5 non pwm channels. There is a limit, after all!!
Comments and code invited
Gareth
I have all three PWM channels doing what I want, ie dimming the LEDs and I'm trying to get the best control/dimming capability out of the other 5 channels.
My understanding is that the PWM command uses an internal module and once set up, "does not get in the way of other code (much)", whereas pulsout deals with each pin I have allocated in turn. I THINK the highest duty cycle for the pulsout will be 20%, (5 pins running the command|) plus a bit of readadc time. The 14M2 is going flatout at 32Mhz and the flicker can't be seen, but of course, each LED is only coming up to a 1/5th of its capability (apart from the PW ones).
I think I'm asking a bit much of the poor little 14M2 and would perhaps be better just switching on/off the 5 non pwm channels. There is a limit, after all!!
Code:
setfreq m32
Do
ReadAdc c.4,b0
pulsout B.0,b0
pulsout B.1,b0
pulsout B.3,b0
pulsout B.5,b0
pulsout c.1,b0
If b0 <> b1 Then
b2=b1+85
b3=b2+85
b1 = b0 min 2
if b1=2 then
b1=0
end if
PwmOut c.0, 63, b1
PwmOut b.2, 63, b2
PwmOut b.4, 63, b3
End If
Loop
Gareth