I have my LM35DZ connected to a MCP3201. The connections between MCP & 877A are as follows:
CLK - PortE.0
Dout - PortE.1
CS - PortE.2
My code is as follows:
Code:
'-----------------Defines & Includes--------------------------------------------
Include "modedefs.bas"
DEFINE SHIFT_PAUSEUS 50
DEFINE	OSC	4

'------------------------Configuration Fuses------------------------------------
#CONFIG
    ifdef PM_USED
        device  pic16F877A, xt_osc, wdt_on, lvp_off, protect_off
    else	
		__CONFIG _XT_OSC & _WDT_OFF & _LVP_OFF & _CPD_ON & _CP_ALL & _PWRTE_ON & _BODEN_ON
   endif
#ENDCONFIG


@ ERRORLEVEL -306			' SUPRESS PAGE BOUNDRY ERROR

DEFINE DEBUGIN_REG	PORTC
DEFINE DEBUGIN_BIT	7
DEFINE DEBUG_REG	PORTC
DEFINE DEBUG_BIT	6
DEFINE DEBUG_BAUD	2400
DEFINE DEBUG_MODE	1

'======================================
'--------------------REGISTERS-------------------------------
ADCON1=7 ' NO ANALOG
CMCON=7						' No Compapator
OPTION_REG=128
TRISA=0 : PORTA=0
TRISB=0 : PORTB=0
TRISC=0 : PORTC=0
TRISD=0 : PORTD=0
TRISE=%00000010 : PORTE=0
CCP1CON=0

'-- ShiftIN/Out pins
CLK	Var PortE.0
DIN Var PortE.1
CS	Var PortE.2
'-------------------

CS=1
Sensor=0

Main:

		CS=0 : pauseus 100
		SHIFTIN Din,Clk,6,[Sensor\12]
		CS=1
		DEBUG DEC Sensor,13,10
		PAUSE 1000
Goto Main
But my readings are not working properly. I get in my terminal window the following:

Code:
38
19
3091
3091
3091
3091
3091
3091
3091
3091
3091
3091
3091
3091
3091
.
.
.
According to my calculations, I should get around 154 as 154 x 1.22(mV) is around 18.8 degrees which seems correct. Please help me identify what have I missed. Thanks