PWM on pic16f1825 issues - 1.pbp v2.60c bug found, fix shown, 2.CCP2 on ALT pin probl


Results 1 to 6 of 6

Threaded View

  1. #1
    Join Date
    Feb 2011
    Posts
    26

    Default PWM on pic16f1825 issues - 1.pbp v2.60c bug found, fix shown, 2.CCP2 on ALT pin probl

    '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
    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
    Issue #1.
    compiled & got
    Code:
    error    [113] c:pbp\pbppi14e.lib 2089: sysmbol not previously defined [CCPTMSR0]

    Code:
    'FROM  MPASM PIC16F1825 processor include: p16F1825.inc
    'CCPTMRS          EQU  H'029E'
    'CCPTMRS0	      EQU  H'029E'  ; ADDED this and it worked just fine
    here's why
    Code:
    'code from    c:pbp\pbppi14e.lib
    'hpwmch2
    ...
    line #2089
    '	movlb	CCPTMRS0 >> 7
    Issue #2: CCP2 does not out put to RA5

    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
    Any thoughts / fixes would be appreciated.
    Last edited by ofuzzy1; - 3rd April 2011 at 09:15.

Members who have read this thread : 0

You do not have permission to view the list of names.

Tags for this Thread

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts