problem with PWM


Closed Thread
Results 1 to 4 of 4

Hybrid View

  1. #1
    Join Date
    Mar 2007
    Posts
    8


    Did you find this post helpful? Yes | No

    Default

    thanx skimax!

    with further investigation i have made a hardware pwm that sets in the background!
    here is the code if anyone needs it

    INCLUDE "MODEDEFS.BAS"


    ' ** Declare Variables **



    Pause 500


    start:

    IF PORTB.7=1 Then

    TRISC.2 = 0 ' Enable PORTC.2 (CCP1) as output for PWM
    T2CON = %00000100 ' Set the Prescaler for 1:1, and turn on TMR2
    PR2 = 255 ' See above calculation for the output period



    CCPR1L = 128 ' MSB of the 10-bit duty value
    CCP1CON.2 = 1 ' Turn on PWM Module one,
    CCP1CON.3 = 1 ' by setting bits 2 and 3 of CCP1CON

    EndIF


    IF PORTB.7=0 Then
    CCPR1L = 0
    CCP1CON.2 = 1 ' Turn on PWM Module one,
    CCP1CON.3 = 1 ' by setting bits 2 and 3 of CCP1CON
    High PORTB.6
    EndIF

    GoTo start







    End

  2. #2
    skimask's Avatar
    skimask Guest


    Did you find this post helpful? Yes | No

    Default

    Quote Originally Posted by mimmmis View Post
    thanx skimax!

    with further investigation i have made a hardware pwm that sets in the background!
    here is the code if anyone needs it
    Or you could just use the HPWM command...

Similar Threads

  1. Low freq PWM problem
    By ultiblade in forum mel PIC BASIC Pro
    Replies: 5
    Last Post: - 17th February 2010, 07:09
  2. Variable PWM PIC18F2431
    By trr1985 in forum mel PIC BASIC Pro
    Replies: 7
    Last Post: - 12th June 2009, 06:03
  3. PWM Problem
    By cihhan in forum mel PIC BASIC Pro
    Replies: 1
    Last Post: - 14th June 2008, 18:43
  4. Problem with PWM using 16F688
    By electrocomp in forum General
    Replies: 9
    Last Post: - 1st December 2007, 14:14
  5. PWM problem CCP2 port
    By NL2TTL in forum mel PIC BASIC Pro
    Replies: 10
    Last Post: - 19th September 2006, 23:34

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