Menu

comparator and Vref

Help
2008-11-01
2013-05-30
  • Nobody/Anonymous

    How does one manage the on board voltage reference (VRCON) and the comparators (CMCON) within GCbasic?

    Thanks.

     
    • kent_twt4

      kent_twt4 - 2008-11-01

      Looking at the 18f4620 datasheet, you would enable the comparator module by choosing the mode (CM2:CM0 bits) you wish to use (GCBasic default is Off or '111').   If you want to use the internal reference voltage, there is only one mode that you can use which is CM2:CM0 = '110'.  You could code by CMCON = b'00000110', CMCON = 6 or individually set the bits CM2=1:CM1=1:CM0=0.  Individually setting the bits is the more portable.  Set the other options available in the CMCON in a similar fashion if required.

      Same thought process for setting up the VRCON register.  Enable the internal Vref, CVREN=1.  Calculate the internal Vref according to the formula, then set/clear the CVRR and CVR3:CVR0 bits.  

       

Log in to post a comment.

Want the latest updates on software, tech news, and AI?
Get latest updates about software, tech news, and AI from SourceForge directly in your inbox once a month.