Re: Shiftin problem (16f877A with MCP3201)
Thanks a lot for the help. It is working. But could you explain my doubts please?

Originally Posted by
Darrel Taylor
I think you need mode 4 in the SHIFTIN.
I understand why clock idles high (as data comes on falling edge), BUT why read before sending clock mode?

Originally Posted by
Darrel Taylor
And it needs to shift 16 bits, not 12. Even though it's a 12-bit result.
Should this be a normal practice or is there something I missed?

Originally Posted by
Darrel Taylor
A few other changes and ... try this ...
Code:
'-------------------
Calibration CON -1 ; Signed value in 0.1 deg. C - Not sure what this does?
Sensor VAR WORD
'-------------------
HIGH CS
Main:
LOW CS
SHIFTIN Din,Clk,4,[Sensor\16]
HIGH CS
Sensor = (Sensor & $FFF) * 5000 ' Understand the first part, we masked the high 4 bits and force them to 0 BUT I dont get the remaining maths, like Why times by 5000? and what does the below statement do
Sensor = DIV32 4095 + Calibration
IF Sensor <= 1500 THEN DEBUG DEC Sensor/10,".",DEC1 Sensor,13,10
PAUSE 1000
Goto Main
___________________
WHY things get boring when they work just fine?
Bookmarks