Updating HPWM frequently, safe?


Results 1 to 40 of 79

Threaded View

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


    Did you find this post helpful? Yes | No

    Default

    first you'll have to match the calc values to suit your need. With your current code example (which seems to be one of mine, the calc will give you...
    <IMG SRC="http://www.picbasic.co.uk/forum/attachment.php?attachmentid=1593&stc=1&d=117840872 7">

    look at this section of the code
    Code:
            duty = 52                           ' duty value for 50% duty cycle
            PR2 = 25                            '
            T2CON = %00000100                   ' timer2 on, prescale 1:1
            CCPR1L = duty>>2                    ' MSB of duty cycle value
            CCP1CON=%00001100 | (dUTY<<5)       ' set PWM mode and store the 
                                                '   2 LSB of duty
    52 is showned in the result section and it's to set the duty cycle to 50% as selected in the duty cyle section.

    Now if you want to update the duty cycle, you could use this section
    Code:
            CCPR1L = duty>>2                    ' MSB of duty cycle value
            CCP1CON=%00001100 | (dUTY<<5)       ' set PWM mode and store the 
                                                '   2 LSB of duty
    in your code you just need to change the value of Duty variable.

    The example was for a 16F877, you should have a look at the 12F683 to see if they work the same way.

    post your whole code, maybe some register need to be set in a different way. I'll put some effort and open my datasheet as well
    Attached Images Attached Images  
    Last edited by mister_e; - 6th May 2007 at 00:52.
    Steve

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

Similar Threads

  1. need help on hpwm
    By helmut in forum mel PIC BASIC Pro
    Replies: 2
    Last Post: - 28th August 2007, 15:49
  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. sound command & music
    By trying in forum mel PIC BASIC Pro
    Replies: 14
    Last Post: - 26th May 2006, 14:14
  4. HPWM and A to D interaction question 18F252
    By tcbcats in forum mel PIC BASIC Pro
    Replies: 7
    Last Post: - 10th May 2006, 03:50
  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