There is (PIN 6 12LF1822) , but I've turned the compartators off...
 
	Code:
	@ __CONFIG _CONFIG1, _FCMEN_OFF & _FOSC_INTOSC & _WDTE_OFF & _MCLRE_OFF & _CP_ON & _IESO_OFF & _BOREN_OFF & _PWRTE_OFF
@ __CONFIG _CONFIG2, _LVP_OFF
DEFINE  OSC 8 
  '
INCLUDE "DT_INTS-14.bas"     ' 
INCLUDE "ReEnterPBP.bas"     ' Include if using PBP interrupts
 
DEFINE HSER_RCSTA 90h ' Enable serial port & continuous receive
DEFINE HSER_TXSTA 24h ' Enable transmit, BRGH = 1
DEFINE HSER_CLROERR 1 ' Clear overflow automatically
DEFINE HSER_SPBRG 16  ' 115200 Baud @ 8MHz, 2.12%
SPBRGH = 0
BAUDCON.3 = 1         ' Enable 16 bit baudrate generator
 
APFCON.2 = 1          ' PUT HSEROUT ON PIN 3 (ra4)
APFCON.0 = 0          ' PUT CCP1 onto RA2 Pin5
 
Osccon = %01110010     'sets the internal oscillator to 8Mhz
 
DEFINE ADC_BITS  8     ' ADCIN resolution  (Bits)
DEFINE ADC_CLOCK 1     ' ADC clock source  (Fosc/8)
DEFINE ADC_SAMPLEUS 50 ' Set sampling time in microseconds 
 
CM1CON0 = 0   ' COMPARATORS OFF
CM1CON1 = 0   ' COMPARATORS OFF
ADCON0 = %00000010     'AN0 Enabled (Pin 5) + ADC On
ADCON1 = %00000000     'set ADC +ve ref to internal VREF (00 is VCC)
'FVRCON = %11000001     ' turn fixed internal voltage reference on & set it to 4.096V (last two bits set the voltage ...01 =1.024V,10=2.048
 
OPTION_REG = 0   'WEAK PULLUPS ENABLED
WPUA.3 = 1    ' RA3 pin 4 enabled (SW1)
IOCAN.3 = 1    'interrupt on -ve going edge (SW1
 
cpscon0 = 0             'turn off capacititve touch
 
'HPWM SETTINGS (MANUAL SETTING OF THE REGISTERS VS THE PICBASIC HPWM COMMAND)
CCP1CON    = %00001100   ' Turn HPWM on on CCP1
TRISA.2 =1               ' Disable the CCP2 pin output driver by setting the bit
CCPR1L.6 = 0             'I'm only using 8 bit PWM so clear the top two bits
CCPR1L.7 = 0             'I'm only using 8 bit PWM so clear the top two bits
PR2= 63                  'THIS SETS THE PWM PERIOD (FREQUENCY) to 15.625KHZ @4MHZ (I hope - not scoped it!)
T2CON = %00000100        'TIMER2 ON 1:1 PRESCALER 1:1 POSTSCALER
TRISA.2 = 0              'Enable the CCP2 pin output driver by setting the bit
 
OPAMP VAR PortA.5
SW1 VAR PortA.3
 
latest_sample var byte
 
TEST1:
adcin 1, latest_sample
hserout [dec latest_sample,13,10]
PAUSE 200
GOTO TEST1
 ADC +Vref is set to be VCC.
 
(Not sure what's going with the formatting - when I copied/pasted  there were heaps of line breaks in my code - to make it easier on the eye!)
				
			
Bookmarks