Code:
	'Alias pins - MAX6675 temp sensor
MXSCLK  VAR     PORTA.0   'Clock
MXCS    VAR     PORTA.1    'Chip Select
MXSO    VAR     PORTA.2   'Serial out
TRISA =%00000000
DEFINE SHIFT_PAUSEUS 100
ADCON1 = 15		' All I/O pins digital
CMCON = 7
TRISD =%00000000 
 'Allocate MAX6875 Variables
MXTemp  VAR     WORD    'raw data from 6675/type K sensor
TempC   VAR     WORD 'BYTE[16]    'converted to degrees C
TempF   VAR 	WORD
 
	Code:
	READ_TEMP:
MXCS = 0  'Chip select low
shiftin MXSO, MXSCLK, 0, [MXTemp\16]   'read the data to MXTemp
MXCS = 1    'Chip select high
TempC = MXtemp >> 5   'right shift the data 5 places to get degrees C (Read the Data sheet)
TempF = ABS(TempC) */ 461
TempF = TempF + 32
 
				
			
Bookmarks