'LESSONS LEARNED
' 1. pbpbasic hpwm 2,64,1 works properly for the 16f1825 for ccp2 on pin7 RC3
' 2. must use TRISC.3 =0 to enable
' 3. needed to add definition for CCPTMRS0 in the MPASM P16F1825.inc
' 4. 16f1825/29 default cpu speed is 500Khz NOT 4Mhz
This code works on pin 7 default for ccp2
Issue #1.Code:'COMPILED FOR PIC16F1825 'for pic16f182x define ccp2_reg PORTC define ccp2_bit 3 'ra5=ccp2 pin 2 VLED DEFINE HPWM2_TIMER 2 dc var byte ANSELA = 0 ' disable A2D ANSELC = 0 CM1CON0 = $0 CM1CON1 = $0 CM2CON0 = $0 CM2CON1 = $0 APFCON0.7 = 1 'assign RX/DT to RA1 from RA5 APFCON1.0 = 0 'assign ccp2 to 1= ra5 0=RC3 ' APFCON1.0 = 1 'assign ccp2 to ra5 FROM RC3 TRISC.3 = 0 ' pimary location for ccp2 pin7 trisa.5 = 0 ' alt location for ccp2 pin2 do for dc =255 to 1 step -1 hpwm 2,dc,1000 pause 100 next dc loop end
compiled & got
Code:error [113] c:pbp\pbppi14e.lib 2089: sysmbol not previously defined [CCPTMSR0]
here's whyCode:'FROM MPASM PIC16F1825 processor include: p16F1825.inc 'CCPTMRS EQU H'029E' 'CCPTMRS0 EQU H'029E' ; ADDED this and it worked just fine
Issue #2: CCP2 does not out put to RA5Code:'code from c:pbp\pbppi14e.lib 'hpwmch2 ... line #2089 ' movlb CCPTMRS0 >> 7
Any thoughts / fixes would be appreciated.Code:'for pic16f182x define ccp2_reg PORTA define ccp2_bit 5 'ra5=ccp2 pin 2 VLED DEFINE HPWM2_TIMER 2 APFCON0.7 = 1 'assign RX/DT to RA1 from RA5 APFCON1.0 = 1 'assign ccp2 to 1= ra5 0=RC3 TRISA.5 =0 ' the other way to enable the pwm output .... hpwm 2,dc,1000





Bookmarks