HSPIIN with MAX6675

Iam trying to use hspiin command to read data from a MAX6675 ADC chip. I modified Peter anderson's code to replace the bit banging portion of his code. When I run the simulation I am geting 0 values for b0 and b1. The code is as follows:
'MAX6675_1.Bas - PICAXE 28X1
'				Define terminal associated with MAX6674 / 6675
' PICAXE 28X1                  MAX6674 / 6675
' CS (OUT3) ----Chip Select---- CS (term 6)
' SCK (OUT4) ------Clock------- SCK (term 5)
' SI (IN7) -Serial out from MAX- SO (term 7)
Symbol  CS = Output3
Symbol  SCK = OutPut5
Symbol  SI = Input1

Symbol Val = W0
Symbol WholePart = W1
Symbol FractPart = B4
Symbol Diga = B5

Symbol N = B6

     GoSub MeasTemp
     GoSub DisplayTemp
     Wait 1
     Goto TOP

     hspisetup spimode11e, spimedium
     pause 5
     low CS ‘ enable chip select 
     high SCK
     hspiin (b0,b1)
     low SCK
Any suggestions?


Senior Member
I'm not 100% sure but with Hspi the hspisetup spimode controls the operation of the clock so try removing the high/low sck lines in your code.
Kiwi, I tried your suggestion and there is no change, I still get 0 value for b0 and b1. But I think that you are right. The problem is somewhere else. I am going to breadboard the circuit and see if I get other values with debug.


Hi Andres, did you ever get you MAX6675 to work with HSPIIN as I'm still using the bit-bang way and think HSPIIN would be neater?


Senior Member
Andres has not logged into the forum for nearly 6 months, so it could be a while before he responds.

I have played around a bit with hSPI in the X2 chips. I discovered that PICAXEs can't do duplex SPI (send and receive in one command) but the MAX6675 doesn't support that any way (no SI pin). It should work fine and will be much, much faster than bit-banging!

Being an 8-bit protocol, you will need to read the SPI data into two bytes (but only one hSPIIn command) - refer to the hSPISetup and hSPIIn command documentation. If you choose the byte registers carefully, the received data can be accessed via the associated word register.


Thanks for that Pete, looks like I could have been waiting a while, it was a long shot anyway as this thread looks like it was from 2007 anyway.