Hi,
We used software spi to communicate with tdc-gp21 and this worked properly. here is our function in bascom avr for sending and receiving a byte:
----------------------------------------------------------------
Function Transceive(byval Value As Byte) As Byte
Local Tempb1 As Byte
Local Tempb2 As Byte
For Tempb1 = 1 To 8
Shift Tempb2 , Left
If Value.7 = 0 Then
Reset Mosi
Else
Set Mosi
End If
Set Sck
Reset Sck
If Miso = 0 Then
Reset Tempb2.0
Else
Set Tempb2.0
End If
Shift Value , Left
Next
Transceive = Tempb2
End Function
-----------------------------------------------------------
note that it's necessary to set zero the SSN line during communication so if you want to send multiple bytes, at first you must zero the SSN line, then send and receive all bytes and finally set to one SSN line again.
example for writing data in register 1:
Reset Ssn
Tempb1 = Transceive(0x81) 'write to register 1 (4 bytes)
Tempb1 = Transceive(0x21)
Tempb1 = Transceive(0x44)
Tempb1 = Transceive(0x57)
Tempb1 = Transceive(0x12)
Set Ssn
-------------------------------------------------
finally you should know that it's mandatory to reset the tdc-gp21 by the reset pin as described in datasheet(apply a negative pulse to the reset pin and wait 500us) before any communication.