What you have to watch out for with SPI is there are specific setup requirements. Either the part clocks data in on rising edge and out on falling edge, or in on falling edge and out on rising edge. Also the clock is either idle low or idle high. This is controlled by the mode byte in the shiftin and shiftout commands.
The next thing is whether the SPI part is unidirectional or biderectional. If there is only one data pin it is unidirectional and you need only one I/O pin. If it is bidirectional
it will have seperate data in and data out pins. You would need to use two different I/O pins for this type.
The other issue you may run into with SPI is that data may need to be shifted in and out at the same time, if the part is bidirectional. So the basic shiftin and shiftout commands wouldn't work. If the part is unidirectional, you need to send a command, using shiftout, then read data, using shiftin.
Bookmarks