chopperwalker
New Member
I have a 20x2 that is interfaced by a 4D LCD through I2C. I also have a MCP3201 that I am trying to shiftin the 12 bit reading off a RTD. SPI would be simple enough if the I2C wasn't using up the lines. My real issue is that my 12 bit data is jumping around. It seems that on start up I am getting the correct value (through debug). I have watched the analog input sit steady. The 12 bit output will cycle about 3-4 random readings before coming around back to what again seems to be the correct reading. For instance, my ADC output should be 3152 at room temp, the analog signal (1.924V)/ref (2.5V)*4096. It will show this value then range from 2000 - 3800 while cycling. I have the same result between to different and new MCP3201 chips.
I have tried Shiftin and a bit-banged method posted here by Jeremy Leach which he adopted from Anderson's site. Both through C.3 since I am running C.0 firmware. I am assuming I have a timing issue. I have racked my brain, on top of it, I have a head cold and can't think anymore. I am hoping for some input here if anyone can spot what I am missing or how to tackle this. Yes, I have read the DS, but my brain is no longer reliable.
Here is my pertinent code:
Don't worry, I'm not a student. I'm an ME in need of some EE or CE help. Thank you in advance.
I have tried Shiftin and a bit-banged method posted here by Jeremy Leach which he adopted from Anderson's site. Both through C.3 since I am running C.0 firmware. I am assuming I have a timing issue. I have racked my brain, on top of it, I have a head cold and can't think anymore. I am hoping for some input here if anyone can spot what I am missing or how to tackle this. Yes, I have read the DS, but my brain is no longer reliable.
Here is my pertinent code:
Code:
#picaxe 20x2 ' Pick the chip
'----------------------- Inputs
Symbol HI = C.3
'----------------------- Outputs
Symbol HCS = C.1
Symbol Hclk = C.2
'----------------------- Initialize
init:
let dirsB = %00000000
let pinsB = %00000000
let dirsC = %10100111
let pinsC = %00000000
let adcsetup = %0000000000000110
setfreq m8
High HCS
High Hclk
'----------------------- Main program cycle
main:
gosub HLT_Temp
pause 1000
goto main
'----------------------- Get HLT Temperature and Store Function
HLT_Temp:
HLT = 0
Low Hclk
Low HCS
High Hclk
Low Hclk
High Hclk 'Sample begins on first rising edge after /CS goes low
Low Hclk
High Hclk
SHIFTIN Hclk,HI,MSBPre_L,(b1/4,b0/8)
' For Counter = 11 to 0 step -1
' Low Hclk ' gets next data bit
' High Hclk
' HLT = HLT * 2 + HI
' Next
High HCS
High Hclk
debug
if HCD = 1 then
HLT = HLT + H_Cal
else
HLT = HLT - H_Cal
endif
put 2, b0
put 3, b1
return