Hello,
I am trying to use the ECCP for a full H-bridge. I can not seem to get it working, any help would be appreciated in resolving my issue... see below.
Code:INCLUDE "Modedefs.Bas" DEFINE OSC 20 ; Set port direction and turn off unused peripherals CMCON = 7 ' shut offcomparators TRISA = %00011111 ' Set PORTA to input "1" or output "0" TRISB = %00000000 ' set portB to output "0" or input "1" TRISC = %00000000 TRISD = %00000000 TRISE = %00000000 ADCON1 = %00001111 ' bit 0 ~ bit 3 sets ports as digital I/O. 1 = digital, 0 = analog ADCON0 = %00000000 ' bit 0 disables A/D converter module. ECCP1CON = %00000000 ' bit 0 ~ bit 3 turns off capture/compare/PWM ; Declare variables and aliases duty var byte PAA var LATA PBB var LATB PCC var LATC PDD var LATD ' used to re/set portD.1, can not use portd.1 = x on latch ports PEE var LATE ; initialize power on state of ports LATA = 0 LATB = 0 LATC = 0 LATD = 0 ' force latches on portD to low LATE = 0 ECCP1CON = %11001100 ' bit 0 ~ bit 3 turns off capture/compare/PWM T2CON = %00010101 ' Turn on Timer2, Prescale=4 PR2 = 249 ' Set PR2 to get 5KHz PWM out duty = 100 ECCPR1L = DUTY ECCP1CON.4 = duty.0 ECCP1CON.5 = duty.1 Mainloop: pauseus 1000 goto mainloop




Bookmarks