Data Sheet
25
ETHERIO24TCPDATASHEET
SENDINGBYTESVIASPI
TosendoutSPIdataonPortAthecommandthatneedstobesentout
requiresan"SA"prefixfollowedbythenumberofbytesyouwanttosend
followedbythedatastream.Tosendoutthefollowingbytes0xFF0xAA
0x55youwouldsendthefollowing"SA"+0x03+0xFF+0xAA+0x55
RECEIVINGBYTESVIASPI
ReceivingbytesviaSPIhappenswhenthebytesaresentout,forevery
bytethatisclockedout,thereisanincomingbytebeingreceived.The
numberofbytesreceivedisdeterminedbythenumberofbytesthathas
beensentout.
InordertoreceivethenumberofbytesthatisexpectedfromtheSPI
device,Nullbyteswillhavetobesentout.SendingouttheNullbytesis
requiredtokeeptheSPIclockrunningsothatthereturndataisclocked
outfromtheSPIslavedevice.
Therearenullbytessentintheexampleimagebelow,thiscanbeseenin
thelasttwobyteswhicharesent(implementedwithdon'tcares)andon
theinputpinyouwillhavethevaliddatafromthedevice.Thevaliddata
willbesentbackinthecommandresponsepacket.
Note:youmayhavetosendoutleadingzero'sanddon'tcaresdependingon
deviceyouarecommunicatingwith.e.g.sevenleadingzero'sthena
startbitaspertheimagebelow.
ExampleimageforSPIcommunicationswiththeMCP3004/3008using8bit
segmentstakenfromtheMCP3004./3008datasheet.
(http://www.microchip.com
)
©
2013ElexolPtyLtd Revision1.3