setting up HPWM


Closed Thread
Results 1 to 9 of 9

Thread: setting up HPWM

  1. #1
    Join Date
    Oct 2006
    Posts
    5

    Question setting up HPWM

    Hi ,

    I want know because using the Picbasic Pro function HPWM the max frequency at any oscillator speed is 32.767 kHz, but and using manual register setup, using 20 MHz Xtal can get 2 MHz.

    manual register setup for 1 mhz PWM PIC 16F873

    PR2 = 4
    T2CON = %0000100
    CCPR1L = 2
    CCP1CON = %00011100

    Freq out 1.0 MHz 50 % Duty Cycle


    interesting link :http://www.micro-examples.com/public...alculator.html

    regards

    sunny

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


    Did you find this post helpful? Yes | No

    Default

    You can't have 2MHZ, it's going to be 1.66666MHZ or 2.5MHZ for that crystal speed

    For 1.66666MHZ and a huge 5 bit resolution
    PR2 = 4
    T2CON = %00000100
    CCPR1L =1
    CCP1CON = %00101100


    For 2.5MHZ and 5 bit resolution
    PR2 = 1
    T2CON = %00000100
    CCPR1L =1
    CCP1CON = %00001100

    don't forget to set the TRISx bit.

    If you really need 2MHZ, 40MHZ or 48MHZ crystal will work.
    Steve

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

  3. #3
    Join Date
    Oct 2006
    Posts
    5


    Did you find this post helpful? Yes | No

    Default

    Hi Steve,


    May be I don't explain me very well ( sorry about my English ! )

    Im concerned why using PBP HPWM function the max freq be 32767 Hz.

    DEFINE CCP1_REG PORTC 'Hpwm 1 pin port
    DEFINE CCP1_BIT 2 'Hpwm 1 pin bit
    DEFINE HPWM2_TIMER 1 'Hpwm 2 timer select

    HPWM 1,127,32767 ' Send a 50% duty cycle PWM signal at 32767 Hz

    ( PBP MANUAL : The highest frequency at any oscillator speed is 32767Hz )


    Settings manually the registers and don't use PBP HPWM function i can get too much frequency range to the ouput of PWM .


    Best Regards

    Sunny

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


    Did you find this post helpful? Yes | No

    Default

    Ok i try again, is the question is Why the HPWM can't provide more than 32.767 KHZ?

    Don't worry about your english... i know what you mean and how hard it is.. i'm french.. but Canadian (cool down Alain )
    Steve

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

  5. #5
    Join Date
    Oct 2006
    Posts
    5


    Did you find this post helpful? Yes | No

    Thumbs up

    Hi Steve ,


    ( Ok i try again, is the question is Why the HPWM can't provide more than 32.767 KHZ? )


    Yes I want know why !



    Regards

    Sunny


    P.S :

    I'm be concerned about some statements used in a code example that you early write in another post.

    (Fullfilling lookup tables )

    @CSize=CODE_SIZE ; get the PIC Codespace size

    LookupStart=(CSize*1024)-512
    ' get the Lookup first address
    ' As i used the bootloader i just move
    ' the adress to a x place

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


    Did you find this post helpful? Yes | No

    Default

    for the frequency limitation i guess it's an assembler maths limitation. it's hard to fit millions or 1/milions in a 16bit maths routine and/or in a Word size variable

    Look in your datahseet to know how to calculate the PR2 value and search for HPWM in PBPPIC14.LIB file to know how the calc are done.

    I'm be concerned about some statements used in a code example that you early write in another post.
    What do you want to know?
    Steve

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

  7. #7
    Join Date
    Oct 2006
    Posts
    5


    Did you find this post helpful? Yes | No

    Smile

    Hi Steve ,


    Thanks you for answer my question !

    My doubts about HPWM be cleared now.

    I learned about PWM and how to setting up registers.

    I don't be working in a project , only want to learn from the forum , thanks to you and all the members this be possible.

    Thanks a lot !

    Another question related to " Fullfilling lookup tables " be the following :


    1 ) From where you get this statement @CSize=CODE_SIZE ?

    2) How work them ?

    3 ) You use in this code (CSize*1024)-512 can explain me about it ?

    Sorry may be too many question !


    Thanks in advance

    Sunny

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


    Did you find this post helpful? Yes | No

    Default

    1 ) From where you get this statement @CSize=CODE_SIZE ?
    From my head

    CODE_SIZE
    this is a PBP internal variable that return the code size of the PIC you use. If i open the 16F877.BAS file in the PBP directory and i scroll a little bit in, i will find the following...
    Code:
    DEFINE  CODE_SIZE 8
    YEAH! 16F877 is a 8K size

    @CSize=CODE_SIZE
    It define an assembler variable

    Later i used
    CSize con EXT

    This allow to have this value available in the PBP code

    3 ) You use in this code (CSize*1024)-512 can explain me about it ?
    8K=8*1024 Bytes
    the -512 is because i used the Bootloader. The bootloader program is usually located at the end of the codespace. so the first Table address is located 512 bytes before the codespace end.
    Last edited by mister_e; - 21st October 2006 at 19:49.
    Steve

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

  9. #9
    Join Date
    Oct 2006
    Posts
    5


    Did you find this post helpful? Yes | No

    Smile

    Hi Steve,

    Great !!


    Thanks a lot for all the explanation !!

    You are right :

    ( There's no problem. Only learning opportunities. )

    Regards

    Sunny

Similar Threads

  1. PICKit2 - warning about configuration words
    By flotulopex in forum mel PIC BASIC Pro
    Replies: 26
    Last Post: - 4th August 2009, 14:01
  2. HPWM of the port of two HPWM
    By ja2rqk in forum mel PIC BASIC Pro
    Replies: 3
    Last Post: - 25th April 2007, 15:05
  3. Setting up 5 HPWM pins on 18F4680
    By tcbcats in forum mel PIC BASIC Pro
    Replies: 1
    Last Post: - 2nd August 2006, 05:54
  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 : 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