Menu

HPWM does not work

Help
JVA
2012-05-15
2013-05-30
  • JVA

    JVA - 2012-05-15

    Hello, I have a PIC 16F88 and the programme is:

       ;Chip Settings
       #chip 16F88,8
       #config OSC=INTRC_IO

       ;Defines (Constants)
       #define PWM_Freq 1
       #define PWM_Duty 50

       DIR PORTB.0 out

       'Main code
       do forever

    'Turn up brightness over 2.5 seconds
    For Bright = 1 to 255
    HPWM 1, 1, Bright
    wait 25 ms
    next

    'Turn down brightness over 2.5 seconds
    For Bright = 255 to 1
    HPWM 1, 1, Bright
    wait 25 ms
    next
       loop

    This programme works well, but with PIC 16F1827 ¡Does not work! The programme is as follow:

    ;Chip Settings
    #chip 16F1827,8
    #config OSC=INTOSC

    ;Defines (Constants)
    #define PWM_Freq 1
    #define PWM_Duty 50

    DIR PORTB.0 out

    'Main code
    do forever

    'Turn up brightness over 2.5 seconds
    For Bright = 1 to 255
    HPWM 1, 1, Bright
    wait 50 ms
    next

    'Turn down brightness over 2.5 seconds
    For Bright = 255 to 1
    HPWM 1, 1, Bright
    wait 50 ms
    next
    loop

    Can you help me?  Thanks

     
  • Nobody/Anonymous

    The 16F1827 has CCP1 on PORTB.3 by default. You can get CCP1 to use PORTB.0 using -

    set  APFCON0.CCP1SEL on
    

    or just set PORTB.3 as an output and use that.

     
  • Nobody/Anonymous

    Thank you very much.
    And …  if I need PORTB.0 and PORTB.3 ?

     
  • Nobody/Anonymous

    Right. I see ….

    For example:

    set APFCON0.CCP1SEL , 0
    DIR PORTB.3 out
    set APFCON0.CCP2SEL, 0
    DIR PORTB.6 out

     

Log in to post a comment.

Want the latest updates on software, tech news, and AI?
Get latest updates about software, tech news, and AI from SourceForge directly in your inbox once a month.