Brandon
- 15th December 2007, 05:51
Hi all,
I got some pic18F2423 chips so I could monitor two pots on two pins at 12bit.
Everything ALMOST works. I can't seem to get the second adc (porta.1) to work.
It is not the pots, if i siwtch them porta.1 stays dead, or i should say, outputs whatever is on porta.0.
Any help would be great, i am sure it is a newbie queston :(
'pic18f2423 with 12bit adc
define OSC 20
DEFINE ADC_BITS 12 'SETS NUMBER OF BITS IN RESULTS 8,10,12
DEFINE ADC_CLOCK 3 'SETS CLOCK SOURCE (RC = 3)
DEFINE ADC_SAMPLEUS 50 'SETS SAMPLING TIME IN MICROSECONDS
ADCON2.7 = 1 'right justify port a
W0 Var WORD
W1 Var WORD
b0 Var w0.Byte0 'high byte of word w0
b1 Var w0.Byte1 'low byte of word w0
b2 Var w1.Byte0 'high byte of word w1
b3 Var w1.Byte1 'low byte of word w1
include "modedefs.bas"
loop:
ADCIN PORTA.0,W0
pauseus 100
ADCIN PORTA.1,W1
pauseus 100
LOW 0 'turn off led for testing
SEROUT PORTB.3, T9600, ["T"] 'TILT
SEROUT PORTB.3, T9600, [#w0,10]
HIGH 0'turn on led for testing
SEROUT PORTB.3, T9600, ["P"] 'PAN
SEROUT PORTB.3, T9600, [#w1,10]
goto loop
end
I got some pic18F2423 chips so I could monitor two pots on two pins at 12bit.
Everything ALMOST works. I can't seem to get the second adc (porta.1) to work.
It is not the pots, if i siwtch them porta.1 stays dead, or i should say, outputs whatever is on porta.0.
Any help would be great, i am sure it is a newbie queston :(
'pic18f2423 with 12bit adc
define OSC 20
DEFINE ADC_BITS 12 'SETS NUMBER OF BITS IN RESULTS 8,10,12
DEFINE ADC_CLOCK 3 'SETS CLOCK SOURCE (RC = 3)
DEFINE ADC_SAMPLEUS 50 'SETS SAMPLING TIME IN MICROSECONDS
ADCON2.7 = 1 'right justify port a
W0 Var WORD
W1 Var WORD
b0 Var w0.Byte0 'high byte of word w0
b1 Var w0.Byte1 'low byte of word w0
b2 Var w1.Byte0 'high byte of word w1
b3 Var w1.Byte1 'low byte of word w1
include "modedefs.bas"
loop:
ADCIN PORTA.0,W0
pauseus 100
ADCIN PORTA.1,W1
pauseus 100
LOW 0 'turn off led for testing
SEROUT PORTB.3, T9600, ["T"] 'TILT
SEROUT PORTB.3, T9600, [#w0,10]
HIGH 0'turn on led for testing
SEROUT PORTB.3, T9600, ["P"] 'PAN
SEROUT PORTB.3, T9600, [#w1,10]
goto loop
end