This reads 16 bits on an SPI device.
The initialisation needs to set tncs and tsc as outputs, and tsio as an input.
This routine is called each time you want to read the temperature.
Code:
readtemp
bcf tncs_port, tncs ;starts on high to low edge
movlw 0x10
movwf count1
read_bit
rlf temp_lsb, f
rlf temp_msb, f ;rotates both bytes left
bsf tsc_port, tsc ;raise clock
bcf temp_lsb, 0 ;clear bit 0
btfsc tsio_port, tsio ;check data from LM95071
bsf temp_lsb, 0 ;set bit 0 if data is set
bcf tsc_port, tsc ;lower clock
decfsz count1, f ;decrement counter
goto read_bit
bsf tncs_port, tncs ;raise Not Chip Select = stop LM95071
return