Hi Scott,
I'm not too familiar with the '675, but don't you need to set your ANSEL register so that GP.1 is an analog input? It looks like only GP.0 is set as analog in.
Arch
Hi Scott,
I'm not too familiar with the '675, but don't you need to set your ANSEL register so that GP.1 is an analog input? It looks like only GP.0 is set as analog in.
Arch
"Data sheets? I ain't got no data sheets. I don't need no data sheets. I don't have to read any stinking data sheets!"
Arch,
You are correct! I have changed this to ANSEL = 51 or ANSEL = %00110011. I have changed this but have the same problem! It only reads 32 over SEROUT2 no change.
If I rem out the ADCIN1 I get the correct value via ADCIN0 checked by multimeter. It only happens when I add ADCIN1. Does it look like the ADCON0 register?
Any other suggestions?
Thanks,
Scott
I've not used ADCIN much, but here's some other things to check:
I don't see anywhere in your code that sets the pins as inputs - you might try setting up the TRISIO register as needed.
In the PBP manual it shows an example like this:
"ADCIN 0, B0 ; Read channel 0 to B0"
The 'channel' is selected with a number rather than port pin name - don't know if that makes any difference or not.
Arch
"Data sheets? I ain't got no data sheets. I don't need no data sheets. I don't have to read any stinking data sheets!"
Here is another way of aproaching the A/D based on some code Melanie posted a long time ago, this uses direct access to the pics registers instead of using PBP's routines:
By changing ADCON0 to different values you should be able to read analog in on all the other analog pinsCode:Analog_In: ANSEL=%00110001 ADCON0=%10000001; ' Enable ADC Module on pin AN0 PauseUS 50; ' 50uS Pause to allow sampling Capacitor to charge ADCON0.1=1 ' Start Conversion While ADCON0.1=1:Wend ' Wait for conversion to complete AnalogIn.Highbyte=ADRESH AnalogIn.Lowbyte=ADRESL ' Read 16-bit Result RETURN
Bookmarks