I saw a post from Bruce in 2005 that says the HPWM command only works on CCP1 & CCP2, but when I look inside the PBP3 version of pbppi14e.lib it looks like it could work for CCPs higher than 2 - is that true? I would dearly love to use the HPWM command rather than load all of the individual registers which the code below is an example (and it doesn't seem to work - I hooked up an LED to pin 11 (RA2) and its only dimly lit).
Can anyone help me out with the PIC16F1825 and getting HPWM to work? Ideally, I'd just like to do this:Code:' *************************************************************** ' Initialization ' *************************************************************** DEFINE OSC 20 ' Set oscillator 20Mhz ' *************************************************************** ' Device Fuses ' *************************************************************** ' PIC chip data sheets can be found here: C:\Program Files\Microchip\MPASM Suite #CONFIG __config _CONFIG1, _FOSC_HS & _WDTE_ON & _PWRTE_ON & _MCLRE_OFF & _CP_OFF & _CPD_OFF __config _CONFIG2, _LVP_OFF #ENDCONFIG DEFINE CCP3_REG PORTA DEFINE CCP3_BIT 2 ANSELA = %00000000 ' Digital only (PortA) ANSELC = %00000000 ' Digital only (PortC) ADCON1 = $0F TRISA = %00000000 ' Make all pins on PortA output TRISC = %00000000 ' Make all pins on PortC output DUTY3 var word ' Set CCP modules to PWM mode CCP3CON = %00001100 ' Mode select = PWM PR2 = $FF '255 T2CON = %00000110 ' TMR2 on 1:!6 prescale DUTY3 = 512 CCP3CON.4 = DUTY3.0 CCP3CON.5 = DUTY3.1 CCPR3L = DUTY3 >> 2 lblLoop: goto lblLoop end
HPWM 3, 127, 20000




Bookmarks