what is wrong am i doing in this code?


Closed Thread
Results 1 to 14 of 14

Hybrid View

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


    Did you find this post helpful? Yes | No

    Default Re: what is wrong am i doing in this code?

    Hi,
    The way you have CMCON configured the comparators are set up like this:
    Name:  CMCON_101.JPG
Views: 1309
Size:  38.0 KB

    You have your inputs connected to RA0 and RA2. CMCON.7, which you've aliased is the output of comparator 2...

    In order to use the internal reference voltage module you must set the comparator mode to 110 instead of 101. Further on, you seem to think that RA2 is the reference input but it's not. It can optionally be the reference output. From the datasheet:
    The output of the reference generator may be connected to the RA2/AN2/VREF-/CVREF pin. This can be used as a simple D/A function by the user if a very highimpedance load is used. The primary purpose of this function is to provide a test path for testing the reference generator function.
    Finally, I can't seem to find a register called VRCON in the datasheet, it's CVRCON.

    You need to decide what to actually do, either use the internal reference and set it up correctly or use external "reference" and connect it to correct pins.

    /Henrik.

  2. #2
    Join Date
    Jan 2012
    Posts
    24


    Did you find this post helpful? Yes | No

    Default Re: what is wrong am i doing in this code?

    Quote Originally Posted by HenrikOlsson View Post
    Hi,
    The way you have CMCON configured the comparators are set up like this:
    Attachment 6347

    You have your inputs connected to RA0 and RA2. CMCON.7, which you've aliased is the output of comparator 2...

    In order to use the internal reference voltage module you must set the comparator mode to 110 instead of 101. Further on, you seem to think that RA2 is the reference input but it's not. It can optionally be the reference output. From the datasheet:

    Finally, I can't seem to find a register called VRCON in the datasheet, it's CVRCON.

    You need to decide what to actually do, either use the internal reference and set it up correctly or use external "reference" and connect it to correct pins.

    /Henrik.
    thanx in advance, i want to use external refence , am taking deep reading on the data sheet then if i see misunderstang i will come back to you

  3. #3
    Join Date
    Jan 2012
    Posts
    24


    Did you find this post helpful? Yes | No

    Default Re: what is wrong am i doing in this code?

    Quote Originally Posted by HenrikOlsson View Post
    Hi,
    The way you have CMCON configured the comparators are set up like this:
    Attachment 6347

    You have your inputs connected to RA0 and RA2. CMCON.7, which you've aliased is the output of comparator 2...

    In order to use the internal reference voltage module you must set the comparator mode to 110 instead of 101. Further on, you seem to think that RA2 is the reference input but it's not. It can optionally be the reference output. From the datasheet:

    Finally, I can't seem to find a register called VRCON in the datasheet, it's CVRCON.

    You need to decide what to actually do, either use the internal reference and set it up correctly or use external "reference" and connect it to correct pins.

    /Henrik.
    1. VRCON register is for internal Vref and is found within a data sheet
    2. CM2:CM0=101 i found from the data sheet and is for "one independent comparator"
    3. from the data sheet i found RA2 is the refereence input
    4. i want to use external fererence as i show in my circuit , i used RA2 as reference
    5. i use pic16f627a/628a/648a datasheet, i found that i configured well but i think the problems are in the loop, check well
    6. still i have a problem Henrik, so ask help on this and it will be better when you stimulate this circuit so that you can see how it perfom wrongly

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


    Did you find this post helpful? Yes | No

    Default Re: what is wrong am i doing in this code?

    Hi,
    Two questions, only one needs answering:
    1) Why on earth do you use the datasheet for the 16F628A when you're using the 16F877A?
    2) If you actually ARE using the 16F628A why on earth do you post a schematic showing that you're using a 16F877A?

    I'm sorry but you're not really making it easy for anyone to help you.

    /Henrik.

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