Hi Andrew,
I think I see the problem. Give this a shot and let me know how it looks;
Code:
DEFINE OSC 20
Duty Var Word
PORTB = 0 ' clear port
TRISB = %11000000 ' PWM0,1,2,3,4,5 outputs
' set up PWM
DTCON = 0 ' 0 dead-time
PTCON0 = %00001000 ' 1:1 postscale, 1:16 prescale, free running mode
PTCON1 = %10000000 ' PWM time base is ON, counts up
PTPERL = $E8 '
PTPERH = $07 ' PTPER = $07E8
PWMCON0 = %01000000 ' PWM 0 to 5 outputs enabled , complementary
PWMCON1 = 1 ' updates enabled and overrides sync
OVDCOND = %11111111
RAMP:
For Duty = 8000 To 0 STEP-1 ' ~3.2% to ~99%
PDC0L = Duty.LowByte
PDC0H = Duty.HighByte
PDC1L = Duty.LowByte
PDC1H = Duty.HighByte
Pause 5
Next Duty
For Duty = 0 To 8000 ' ~99% to ~3.2%
PDC0L = Duty.LowByte
PDC0H = Duty.HighByte
PDC1L = Duty.LowByte
PDC1H = Duty.HighByte
Pause 5
Next Duty
GoTo RAMP
End
Bookmarks