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.
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
How does one manage the on board voltage reference (VRCON) and the comparators (CMCON) within GCbasic?
Thanks.
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.