Hello
New problem, I was using a MCP3202 ADC and was liking it but I need more inputs. I designed a board around the MCP3208 because the commands looked like they would be fairly similar. I can not get a valid stable number out of the MCP3208.
I have AGND and DGND both hooked to GND because I dont have a seperate GND for each. My power is 5V and my Vref is 5V.
If I hook ch0 input to ground I get 0 to display on my LCD but if I hook ch0 to 5v I get a value bouncing from 1023 to 3071. Alternating everytime the lcd displays the next fetched value from the ADC. I am using it as a single-ended ADC and I give it a command of %1000.
This device seems pretty straight forward but I cant get it to work.
Here is the code I am using
Define OSC 40
pause 1000
Include "modedefs.bas"
Trisc.0 = 0 ' Sets PortC Pin 0 to Output.
Trisc.1 = 0 ' Sets PortC Pin 1 to Output.
CS Var PortC.0 ' Chip Select (MCP3208.10).
Clock Var PortC.1 ' Clock (MCP3208.13).
DataIn VAR PortC.2 ' --> Data Out (MCP3208.12).
DataOut Var PortC.5 ' <-- Data In (MCP3208.11).
LCD Var portC.3 ' LCD Data debuging pin.
result0 VAR Word ' Conversion Result CH0
result0 = 0
high CS ' Disables MCP308 AD Chip.
Pause 500 ' Pause to allow lcd to bootup.
Serout2 LCD,16468,[12,"MCP3208 Test"]
Pause 5000 ' Pause to see display on LCD.
Main:
LOW CS ' Enable ADC
SHIFTOUT DataOut, Clock, MSBFIRST, [%1000\4] ' Select CH0, Single-Ended
SHIFTIN DataIn, Clock, MSBPOST, [result0\12] ' Read ADC
HIGH CS ' Disable ADC
Serout2 LCD,16468,[12,Dec result0] 'Display CH1 on LCD.
PAUSE 1000 'Pause long enough to read LCD.
Goto Main
Thanks
Shawn
Bookmarks