18f4431 pwm4 and pwm 5 issues
Hello All,
I have a brushless DC motor and want to build my own drive control for the unit. I can get the device to throw out PWM's on ports 0,1,2,3 but nothing on 4 or 5. I am getting something from portb.4 and portb.5 but it is not the pwm's i have on the lower ports.
My code is a mish mash of others to get something working to build upon but hopefully someone can spot my error.
Device 18F4431
XTAL = 20
Dim Duty As Word
Duty = 800
PORTB = 0 ' clear port latch
TRISB = %11000000
PTCON0=$00 timebase
PTPERL=$A0 ' $01A0 = 12kHz
PTPERH=$01
PWMCON0=%01010111
PWMCON1=%00000001
DTCON=$00
OVDCOND = %00000000
OVDCONS = %00000000 PORT PINS
SEVTCMPL=$00
SEVTCMPH=$00
PDC0L=$00
PDC0H=$00
PDC1L=$00
PDC1H=$00
PDC2L=$00
PDC2H=$00
PDC0L = Duty.LowByte
PDC0H = Duty.HighByte
PDC1L = Duty.LowByte
PDC1H = Duty.HighByte
PDC2L = Duty.LowByte
PDC2L = Duty.HighByte
PTCON1=%10000000
MAIN:
OVDCOND = %00111111
DelayMS 500
OVDCOND = %00000000
DelayMS 500
GoTo MAIN
Many thanks
Lothar
the basics...its always the basics
As promised I have found the resolution to my problem (the PWM issue not the posting on the wrong forum issue) after much soul searching and datasheet reading I tracked it down to be a typo.
the line:
Quote:
PDC2L = Duty.LowByte
PDC2L = Duty.HighByte
should have been:
Quote:
PDC2L = Duty.LowByte
PDC2H = Duty.HighByte
the code works fine now and I can now move through the commutation pattern of the brushless motor drive. I cant believe it came to this damn you cut-copy-paste.
Once again I apologies for posting here :o