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