Is it possible to change HPWM duty cycle without restarting the PWM generator?


Closed Thread
Results 1 to 4 of 4

Hybrid View

  1. #1
    Join Date
    Feb 2013
    Posts
    1,124


    Did you find this post helpful? Yes | No

    Default Re: Is it possible to change HPWM duty cycle without restarting the PWM generator?

    Sounds simple, but hard to do:

    24.3.2 SETUP FOR PWM OPERATION
    The following steps should be taken when configuring
    the CCP1 module for standard PWM operation:
    1. Disable the CCP1 pin output driver by setting
    the associated TRIS bit.
    2. Load the PR2 register with the PWM period
    value.
    3. Configure the CCP1 module for the PWM mode
    by loading the CCP1CON register with the
    appropriate values.
    4. Load the CCPR1L register and the DC1B1 bits
    of the CCP1CON register, with the PWM duty
    cycle value.
    5. Configure and start Timer2:
    • Clear the TMR2IF interrupt flag bit of the
    PIR1 register. See Note below.
    • Configure the T2CKPS bits of the T2CON
    register with the Timer prescale value.
    • Enable the Timer by setting the TMR2ON
    bit of the T2CON register.
    6. Enable PWM output pin:
    • Wait until the Timer overflows and the
    TMR2IF bit of the PIR1 register is set. See
    Note below.
    • Enable the CCP1 pin output driver by clearing the associated TRIS bit.

    I guess, I need to alter step #4 each time, but how to do that in PBP is beyond my understanding...

  2. #2
    Join Date
    Oct 2005
    Location
    Sweden
    Posts
    3,612


    Did you find this post helpful? Yes | No

    Default Re: Is it possible to change HPWM duty cycle without restarting the PWM generator?

    Hi,
    It's really not that complicated and there's plenty of code floating around the forum showing how it's done and discussions about how it works and how the values interact.
    If you really can not find the info please enlighten us regarding the device used, clock frequency and desired PWM frequency?

    /Henrik.

Similar Threads

  1. HPWM with zero duty cycle on PIC18F2550
    By missouri100 in forum mel PIC BASIC Pro
    Replies: 5
    Last Post: - 27th February 2014, 01:39
  2. 3 channel PWM with customize duty cycle
    By photoelectric in forum mel PIC BASIC Pro
    Replies: 56
    Last Post: - 16th May 2011, 13:49
  3. Replies: 9
    Last Post: - 8th October 2008, 11:15
  4. PWM PIN(S), DUTY, CYCLE ?Plural possible?
    By earltyso in forum mel PIC BASIC Pro
    Replies: 3
    Last Post: - 17th November 2007, 20:41
  5. PWM _ Duty Cycle in Tenths
    By rwskinner in forum mel PIC BASIC Pro
    Replies: 11
    Last Post: - 17th May 2004, 12:09

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