1 Continuous MCPWM at a time


Results 1 to 40 of 47

Threaded View

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


    Did you find this post helpful? Yes | No

    Default Re: 1 Continuous MCPWM at a time

    Something like this might help so it doesn't drop-off the end and restart from the beginning. It also loads the new duty-cycle values.

    Code:
    PTCON1=%10000000
    OVDCOND = %00000010 'PWM on PWM1
     
    Main:
       ADCON0.1 = 1         ' Start the conversion
       While ADCON0.1=1     ' Wait for it to complete
       Wend
       Duty.HighByte = ADRESH ' get result from AN0
       Duty.LowByte = ADRESL  ' Increment buffer pointer
       PDC0L = Duty.LowByte
       PDC0H = Duty.HighByte
       PDC1L = Duty.LowByte
       PDC1H = Duty.HighByte
       PDC2L = Duty.LowByte
       PDC2H = Duty.HighByte
       GoTo Main
    It's untested, but should work. I didn't check the A/D part, but it looks ok at a glance.

    You might want to insert a PAUSE before the GOTO Main?
    Last edited by Bruce; - 13th July 2011 at 11:46.
    Regards,

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

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