18F4431 - Complementary mode PWM
I'm using the power control module of a PIC18F4431 to control some Constant current sources for some high power leds. For these CCS devices a "1" = "off" so I though to myself why not use the complementary mode on the PWM module then on my even channels I'll get 1's and on the odds 0's. Wrote a little code to ramp the leds up and down but the even channels are staying at full power while the odds are ramping as expected. If i put it into independent mode all leds ramp together so it isn't something I've snafu'd on the ccs connections.
Here's the code, any idea where I'm going wrong ?
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 = %01000011 ' PWM 0 to 5 outputs enabled , complementary
PWMCON1 = 1 ' updates enabled and overrides sync
OVDCOND = %11111111
RAMP:
For Duty = 2024 To 0 STEP-1 '
PDC0L = Duty.LowByte
PDC0H = Duty.HighByte
PDC1L = Duty.LowByte
PDC1H = Duty.HighByte
Pause 5
Next Duty
For Duty = 0 To 2024 '
PDC0L = Duty.LowByte
PDC0H = Duty.HighByte
PDC1L = Duty.LowByte
PDC1H = Duty.HighByte
Pause 5
Next Duty
GoTo RAMP
End
Thanks, Andrew
Re: 18F4431 - Complementary mode PWM
Hi
I am using 18f4431 ,too.I want to run AN900 (microchip).I were unable to send.This program ,it works isis.But I were unable to run 18f4431.
Please help me.
Thanks
Re: 18F4431 - Complementary mode PWM
Hi,
Without your code it's hard to say. But if it runs in isis and not in the actual circuit.
The problem is probably in your configuration settings. Did you set the High-side/low-side transistor polarity?
Post your code and configurations and someone will help.
Re: 18F4431 - Complementary mode PWM
Hi Mark_s , I would like to apologize for that I enter conversation between. I am new in the pic issue.I dont know configuration settings.Only do you need to hex file?
https://rapidshare.com/files/854468532/AN900DNM.rar