
Originally Posted by
Joe S.
Hello,
Edited.
Code:
INTCON = %10001000 'internal oscillator
OSCCON = %01110000 ' 8mHz
CMCON0 = 7 'Comparators off
GPIO = %00000000 'outputs low
TRISIO = %00010000 'GP4 as input
ANSEL = %00111000 'AN3 analog
'Define ADCIN parameters
Define ADC_BITS 10 ' Set number of bits in result
Define ADC_CLOCK 3 ' Set clock source (3=rc)
Define ADC_SAMPLEUS 50 ' Set sampling time in uS
'Define CCP1_REG GPIO 'PWM Output on gpio
'Define CCP1_BIT 2 'Bit 2
' Variables
Posit var Word
Speed var byte
Pause 100
Scan:
ADCIN 3, Posit ' Read channel AN3 to Posit
Speed = Posit/4
HPWM 1,Speed,1000
Pause 10
Goto Scan
End
OK, I'm still trying to understand this and use code, so I thought that I would revive this thread.
Above, the code has "ANSEL = %00111000 'AN3 analog" To me it looks like AN4 and 5 are also made analog. Is this needed? if it is not needed, I should be able to use:
Code:
ANSEL = %00001000 ' AN3 analog
~ Dave
Bookmarks