16f877 generate pwm according 2 analog input


Closed Thread
Results 1 to 7 of 7

Hybrid View

  1. #1
    Join Date
    Nov 2003
    Location
    Wellton, U.S.A.
    Posts
    5,924


    Did you find this post helpful? Yes | No

    Default

    Welcome to the forum.

    First thing I see in the code "main-loop" it just stops, no return, goto or even a THEN to go with the IF.

    Second thing. If the only place you are trying this is on a simulator, good luck.
    Use a bread board for your simulator.
    Dave
    Always wear safety glasses while programming.

  2. #2
    Join Date
    Jul 2003
    Location
    Colorado Springs
    Posts
    4,959


    Did you find this post helpful? Yes | No

    Default

    There's more to the code.
    For some reason vBulletin saw "Reference&lt;Voltage" as being HTML and it messed up the post. I added a space, and now it shows the whole thing.<hr>
    I think Proteus is complaining about using ADCON0=%11000001.
    A/D Clock mode 3 is not recommended at 20mhz, but I wouldn't call it an error.
    Using ADCON0 = %10000001 might clear the problem, by selecting FOSC/32, which is what the comments say you wanted anyhow.

    But I think the biggest problem is that the execution from the beginning falls into the get_reference Subroutine.
    When it hits the RETURN, it has no idea where to go, because nothing GOSUB'd to it to begin with.
    You should have a GOTO main_loop before that point.

    You should also put some limits on CCPR1L.
    It shouldn't go above PR2 (49) or try to go below 0.
    Just some IF statements will fix that.

    hth,
    DT

Similar Threads

  1. Variable PWM PIC18F2431
    By trr1985 in forum mel PIC BASIC Pro
    Replies: 7
    Last Post: - 12th June 2009, 07:03
  2. How to generate sine PWM using 16f877
    By kvrajasekar in forum mel PIC BASIC Pro
    Replies: 3
    Last Post: - 12th September 2008, 09:40
  3. Microcontroller with 2 way paging application problem
    By oneohthree in forum mel PIC BASIC Pro
    Replies: 30
    Last Post: - 20th April 2007, 18:27
  4. 10bits adc using 16f877
    By sixty9sandals in forum mel PIC BASIC
    Replies: 7
    Last Post: - 8th March 2007, 19:23
  5. Can anyone help a beginner in a struggle?
    By douglasjam in forum mel PIC BASIC
    Replies: 1
    Last Post: - 6th May 2005, 00:29

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