Help changing CCP3 output pin


Closed Thread
Results 1 to 3 of 3
  1. #1
    Join Date
    Jul 2006
    Posts
    36

    Default Help changing CCP3 output pin

    Hello experts,

    Yes, I live in NoobieVille.

    I am using a 16f877a and have a need to use a 3rd PWM output, which I found code from Bruce on how to do this. So far so good. It follows below.

    However, I can't find how to change the output for CCP3 to use an alternate pin. All my Port A (A/D channels,) Port B (user input,) and port D (user input,) are used. Port E is multiplexed to ADCON inputs according to the datasheet. But I could use pin C.3,4,5,6,or 7. And after all outputs for the other PWMs are on C.1 and 2, so the next C pin would be logical.

    Is it even possible to do it?

    Thanks a bunch for any guidance. The project is coming along nicely and I am pretty excited when stuff works right. I'm learning, albeit S-l-o-w-l-y. I'm gettin' older...

    Here is Bruce's contribution form a previous post about using 3 HPWMs:


    -----------------------------------------------------------------
    Duty1 var Byte 'Variable for controlling the PWM in CCP1
    Duty2 Var Byte 'Variable for controlling the pwm in CCP2
    Duty3 Var Byte 'Variable for controlling the PWM in CCP3


    CCP1CON = %00001100 'Using CCP1 as PWM Mode Register 9-1 in Datasheet
    CCP2CON = %00001100 'Using CCP2 as PWM Mode Register 9-1 in Datasheet
    CCP3CON = %00001100 'Using CCP3 as PWM Mode Register 9-1 in Datasheet
    T2CON = %00000101

    TRISC.2 = 0 'Setting the CCP1 PIN as OUTPUT
    TRISC.1 = 0 'Setting the CCP2 PIN as OUTPUT
    TRISB.5 = 0 'Setting the CCP3 PIN as OUTPUT

    Duty1 = 0
    Duty2 = 0
    Duty3 = 0


    ' Fosc = Clock Frequency (4MHz)
    ' PS = Timer2 Prescale Value (T2CON<1:0>)
    ' Freq = PWM output frequency
    ' Duty% = Duty cycle (20% = 0.2)

    ' formulas:
    ' PR2=(Fosc/(4*PS*Freq))-1
    ' CCPR1L:CCP1CON<5:4>=(PR2+1)*4*Duty%

    PR2 = 50 with prescalar of 4 in Timer2

    For i = 0 to 200
    Duty1 = Duty1 + 1
    CCP1CON.4 = Duty1.0
    CCP1CON.5 = Duty1.1
    CCPR1L = Duty1 >> 2
    Pause 17
    Next i

    For i = 0 to 200
    Duty2 = Duty2 + 1
    CCP2CON.4 = Duty2.0
    CCP2CON.5 = Duty2.1
    CCPR2L = Duty2 >> 2
    Pause 17
    Next i


    for i = 0 to 200
    Duty3 = Duty3 + 1
    CCP3CON.4 = Duty3.0
    CCP3CON.5 = Duty3.1
    CCPR3L = Duty3 >> 2
    Pause 17
    Next i

  2. #2
    Join Date
    Jul 2006
    Posts
    36


    Did you find this post helpful? Yes | No

    Default

    Oops, looks like this won't work with the 16f877A. I get an undefined CCP3CON Symbol error.

  3. #3
    Join Date
    Jul 2003
    Posts
    2,405


    Did you find this post helpful? Yes | No

    Default

    Looks like you might have stumbled onto a code example for a 16F7X7 type with 3 CCP
    modules. Unfortunately the 877A only has two.
    Regards,

    -Bruce
    tech at rentron.com
    http://www.rentron.com

Similar Threads

  1. Is this a K Type sensor?
    By jessey in forum mel PIC BASIC Pro
    Replies: 20
    Last Post: - 21st November 2009, 13:55
  2. Output pin drop too high
    By George in forum Off Topic
    Replies: 3
    Last Post: - 15th July 2007, 21:58
  3. Microcontroller with 2 way paging application problem
    By oneohthree in forum mel PIC BASIC Pro
    Replies: 30
    Last Post: - 20th April 2007, 17:27
  4. Serious Serial Situation Setbacks...
    By Dansdog in forum mel PIC BASIC Pro
    Replies: 5
    Last Post: - 7th February 2007, 03:46
  5. Another RTC, DS1287
    By DavidK in forum Code Examples
    Replies: 0
    Last Post: - 12th December 2006, 17:07

Members who have read this thread : 1

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

Posting Permissions

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