hpwm more than 2 ch possible in pbp?????????


Closed Thread
Results 1 to 21 of 21

Hybrid View

  1. #1
    oscar's Avatar
    oscar Guest

    Unhappy hpwm more than 2 ch possible in pbp?????????

    i am wondering if it is at all possible to have more than 2 ch of hpwm within pbp????????????? i am using a pic16f767 with 3 hpwn chs yet i can only seem to get 2 running?? ch 2 seems to be mixed/ shared with ch 3 for some reason.. ie ccp1 is fine but when i write a value to ccp2 it shows up on ccp3!!!!!!! im boggled.. i have tryed all the possible reg configs i can think of yet still no joy... has anyone got any pointers??? i am totally stuck here !! lol.

    thank you
    oscar..

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


    Did you find this post helpful? Yes | No

    Default

    i am wondering if it is at all possible to have more than 2 ch of hpwm
    within pbp?


    Nope. The HPWM command only supports 2 channels. CCP1 & CCP2. You
    would need to modify the 16F library to support CCP3. It's much easier to
    just configure hardware PWM manually.

    From the examples in your 16F767 datasheet;

    Setup 10-bit PWM for 1.22kHz with a 20MHz osc.

    ' Word vars for 10-bit value of each PWM duty cycle
    Duty1 VAR WORD ' Channel #1
    Duty2 VAR WORD ' #2
    Duty3 VAR WORD ' #3

    ' Set CCPx pins to outputs
    TRISC.2=0 ' CCP1 output
    TRISC.1=0 ' CCP2 output (could also be assigned to RB3)
    TRISB.5=0 ' CCP3 output

    ' Set CCP modules to PWM mode
    CCP1CON = %00001100 ' Mode select = PWM
    CCP2CON = %00001100 ' Mode select = PWM
    CCP3CON = %00001100 ' Mode select = PWM

    ' Set period up for 1.22kHz PWM freq
    PR2 = $FF

    ' Set TMR2 up for 1:16 prescale & turn it on
    T2CON = %00000110 ' TMR2 ON 1:16 prescale

    Duty1 = 512 ' 50% duty cycle. 1024/2 "10-bit resolution"
    CCP1CON.4 = Duty1.0 ' Setup 10-bit duty cycle as
    CCP1CON.5 = Duty1.1 ' a 10-bit word
    CCPR1L = Duty1 >> 2

    Duty2 = 512
    CCP2CON.4 = Duty2.0
    CCP2CON.5 = Duty2.1
    CCPR2L = Duty2 >> 2

    Duty3 = 512
    CCP3CON.4 = Duty3.0
    CCP3CON.5 = Duty3.1
    CCPR3L = Duty3 >> 2

    You have the same frequency on all three channels since all three channels
    share the same period register, but you have individual control of duty cycle
    on each channel using the corresponding CCPRxL & CCPxCON registers.

    With 10-bit resolution you can have from 0-1023 or 0%-100% duty cycles.

    Pretty simple don't you think?
    Regards,

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

  3. #3
    oscar's Avatar
    oscar Guest


    Did you find this post helpful? Yes | No

    Angry ccp3 dont exist????

    hi bruce, thanx for your reply.

    i have tryed in vain to get your code working cos when i try to compile it it says the following..

    error hwpm.asm 'ie name of project


    undefined symbol ccp3con


    it wont recognise the ccp3con setup for some reason.....

    hence it wont compile.!!

    i had another look at the pbp manual and its very misleading re hpwm as it makes referance to hpwm3 etc yet it does not state that a max of 2 x hpwm are available in pbp!!!! so one would assume that the ref to hpwm3 etc would mean it could use any available hpwm port on a particular chip !!!!!! arrrgggggggggggggggg

    oscar

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


    Did you find this post helpful? Yes | No

    Default

    A few things to look for;

    Never save your basic code file with the exact same name as a PBP
    command, or the same name as the PIC target.

    Try saving it with a name like PWM_F767.bas or something. It compiles
    fine for me with PM or MPASM assemblers with PBP v2.46.

    Be sure you're selecting the 16F767 before compiling, you have a version
    of PBP that supports this device (at least v2.45), and if you're using MPASM
    make sure you have a version of MPASM that supports this PIC.

    Some of the older 17C7xx PIC's had channel 3 which could use timer1. The
    PBP define in the manual shows how to assign timer1 to this channel instead
    of timer2. There are also defines to assign different pins to CCP outputs, but
    I don't see anything in the PBPPIC14.LIB file for the HPWM command that will
    support more than CCP1 & CCP2.

    I don't have one of the 16F767's to mess with, but that code example should
    work assuming you have a version that supports this PIC, you're saving your
    basic file with a name that doesn't clash with a PBP command, and you have
    all the device header files required for this target.
    Regards,

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

  5. #5
    oscar's Avatar
    oscar Guest


    Did you find this post helpful? Yes | No

    Red face oops my mistake...........

    im so duhhhhhhhhhh.. lol the no ccp3 mystery is sloved... i somehow had another chip type selected!!!!!

    question.... would their be any reason with the code u gave me bruce as to why ch2 hpwm2 that is flickers when at a low value?


    thanx

    oscar

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


    Did you find this post helpful? Yes | No

    Default

    What exactly do you mean by flicker?
    Regards,

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

  7. #7
    Join Date
    Sep 2004
    Location
    montreal, canada
    Posts
    6,898


    Did you find this post helpful? Yes | No

    Default

    is this LED flickering happen only with channel2 ? what about if you change the frequency?
    Steve

    It's not a bug, it's a random feature.
    There's no problem, only learning opportunities.

Similar Threads

  1. HPWM of the port of two HPWM
    By ja2rqk in forum mel PIC BASIC Pro
    Replies: 3
    Last Post: - 25th April 2007, 15:05
  2. Microcontroller with 2 way paging application problem
    By oneohthree in forum mel PIC BASIC Pro
    Replies: 30
    Last Post: - 20th April 2007, 17:27
  3. Replies: 2
    Last Post: - 10th July 2006, 01:05
  4. sound command & music
    By trying in forum mel PIC BASIC Pro
    Replies: 14
    Last Post: - 26th May 2006, 14:14
  5. 3 HPWM channels
    By docwisdom in forum mel PIC BASIC Pro
    Replies: 9
    Last Post: - 4th April 2006, 02:43

Members who have read this thread : 0

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