In this session, we will talk about the SPI write and read process. Currently, our chipset W3150A+ and W5100 supports SPI mode 0. It's important to know which mode your SPI uses. Or else it wont work at all. Please make sure that your MCU supports SPI mode 0.
Anyway it is very basic to use the SPI interface. Basically you just have to follow the format below:
For the write operation, you should write the OP-code 0xF0 (11110000) follow by the 2 bytes address and finally the 1 byte of data which you wanted to write.
For the read operation, you should write the OP-code 0x0F (00001111) follow by the 2 bytes address. Then, our chip will send you the 1 byte of data by the MISO line.
The SPI follows the timing diagram below:
Notice in the timing diagrm:
When sending the OP-CODE, the MISO line is 0x00.
When sending the address, the MISO line is 0x01 follow by 0x02
When the data is written, the MISO line is 0x03.
When the data is read, the MISO line is the requested data.
I hope you enjoy my article Thanks!
Tuesday, September 22, 2009
Subscribe to:
Post Comments (Atom)
No comments:
Post a Comment