Pic18f452 pwm1 and pwm2 help


Closed Thread
Results 1 to 10 of 10
  1. #1
    Join Date
    Jun 2008
    Location
    Varese , Italy
    Posts
    326

    Default Pic18f452 pwm1 and pwm2 help

    Good day forum,
    I am not able to have pwm1 and pwm2 working : I just have pwm1 working.
    The system is like this:
    >pic18f452 at 40 Mhz
    >pbp 2.50
    >windows 7 64 bit
    I found on the specification that two PWM's are available but I also found that the same spec calls out pwm2 at pin 16 and pin 36 : any reason ?
    What is the pibasic set_up to get both PWM's operating ?
    Thanks in advance for the asistance.
    regards,
    Ambrogio

  2. #2
    Join Date
    Jun 2008
    Location
    Varese , Italy
    Posts
    326


    Did you find this post helpful? Yes | No

    Default Re: Pic18f452 pwm1 and pwm2 help

    correction:
    I am really using the HPWM 1 and 2 in my code . I am sorry to have called it pwm1 and pwm2...
    I used this lines of code:

    HPWM 1,127,15000
    HPWM 2,64,15000

    but i only have output on hpwm 1 .
    Any help please .
    Thanks
    regards,
    Ambrogio

  3. #3


    Did you find this post helpful? Yes | No

    Default Re: Pic18f452 pwm1 and pwm2 help

    Hi Ambrogio. Make sure you have HPWM2 enabled in your config's.

  4. #4
    Join Date
    Jun 2008
    Location
    Varese , Italy
    Posts
    326


    Did you find this post helpful? Yes | No

    Default Re: Pic18f452 pwm1 and pwm2 help

    thanks Peterdeco1,
    could you please jnstruct me to do it?
    Do I have to use some defines ? Which ones ?
    hope to read from you.
    regards,
    Ambrogio

  5. #5
    Join Date
    Feb 2011
    Posts
    60


    Did you find this post helpful? Yes | No

    Default Re: Pic18f452 pwm1 and pwm2 help

    I had that problem caused by the configs of tiny bootloader, redirects HPWM2 to another pin on 18F4620...

    ' __CONFIG _CONFIG3H, _MCLRE_ON_3H & _PBADEN_OFF_3H ; & _CCP2MX_PORTBE_3H ; NOTE CCP2MX_PORTBE_3H COMMENT OUT

  6. #6
    Join Date
    Jun 2008
    Location
    Varese , Italy
    Posts
    326


    Did you find this post helpful? Yes | No

    Default Re: Pic18f452 pwm1 and pwm2 help

    The point is that there is no output on any pin of the PIC18 relevant to the pwm2.
    I did check all the pins using the scope.
    I have good output for pwm1 only.
    I uded the HPWM of the picbasic pbp2.50 as above: so the output should be at the hardware pins c1 and c2 if the spec os correct.
    Is there someone that was able to get two PWM's output from the pic18f452 ? ( of course having the same frequency but a different duty cycle ).
    Thanks
    Ambrogio

  7. #7
    Join Date
    May 2013
    Location
    australia
    Posts
    2,387


    Did you find this post helpful? Yes | No

    Default Re: Pic18f452 pwm1 and pwm2 help

    DEFINE CCP2_REG PORTC 'Channel-2 port
    DEFINE CCP2_BIT 1 'Channel-2 bit

    might help

    assuming you are using portc.1 for ccp2

    could even try trisc.1=0 also


  8. #8
    Join Date
    Jun 2008
    Location
    Varese , Italy
    Posts
    326


    Did you find this post helpful? Yes | No

    Default Re: Pic18f452 pwm1 and pwm2 help

    Thanks Richard,
    no way for me to get output for both pwm's:
    I did try your suggestion too.
    Pls: see the attached code.
    regards,
    Ambrogio
    Attached Files Attached Files

  9. #9
    Join Date
    May 2013
    Location
    australia
    Posts
    2,387


    Did you find this post helpful? Yes | No

    Default Re: Pic18f452 pwm1 and pwm2 help

    __CONFIG _CONFIG3H, _CCP2MX_OFF_3H puts ccp2 onto portb.3
    use

    DEFINE CCP2_REG PORTB 'Channel-2 port
    DEFINE CCP2_BIT 3 'Channel-2 bit

    or
    __CONFIG _CONFIG3H, _CCP2MX_ON_3H


    or set trisb.3 to 0 and trisc.2 to 0 and CCP2CON=12



    from data sheet
    bit 0 CCP2MX: CCP2 Mux bit
    1 = CCP2 input/output is multiplexed with RC1
    0 = CCP2 input/output is multiplexed with RB3

  10. #10
    Join Date
    Jun 2008
    Location
    Varese , Italy
    Posts
    326


    Did you find this post helpful? Yes | No

    Default Re: Pic18f452 pwm1 and pwm2 help

    Richard,
    thanks very much for the great help in solving my problem.
    The output of pwm2 is now available on B3: very good !
    All the best
    Ambrogio

Similar Threads

  1. pic18f452 ADC
    By hamid_knight in forum General
    Replies: 3
    Last Post: - 15th December 2009, 16:42
  2. Shiftin pic18f452
    By TonyA in forum mel PIC BASIC Pro
    Replies: 8
    Last Post: - 18th August 2009, 10:38
  3. PIC18F452.INC not found
    By isaac in forum mel PIC BASIC Pro
    Replies: 7
    Last Post: - 27th March 2008, 00:53
  4. Pic18F452
    By TonyCNC in forum mel PIC BASIC Pro
    Replies: 22
    Last Post: - 25th July 2007, 06:29
  5. pic18f452 programmer
    By ahmet2004 in forum Schematics
    Replies: 1
    Last Post: - 19th July 2004, 09:20

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