Created
August 7, 2012 02:07
-
-
Save brooksware2000/3280697 to your computer and use it in GitHub Desktop.
MAX6675 temperature sampling routine. Routine stores sampled values in an array and returns the average.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
'------------------------------------------------------------------------------- | |
' Read temperature | |
'------------------------------------------------------------------------------- | |
READ_TEMPERATURE: | |
'Get a sampling of temperature values and write to temperature array | |
FOR index = 0 TO BUFFERSIZE - 1 | |
LOW CS | |
SHIFTIN DAT, CLK, 0,[curTemp\16] | |
HIGH CS | |
ARRAY_TEMPS[index] = curTemp>>5 | |
PAUSE 179 | |
NEXT index | |
curTemp = 0 | |
'Add up all the values in the array | |
FOR index = 0 TO BUFFERSIZE - 1 | |
curTemp = curTemp + ARRAY_TEMPS[index] | |
NEXT index | |
'Take an average of the temperature values | |
curTemp = curTemp/BUFFERSIZE | |
RETURN |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment