SPI Information
(C) 2006-2011 André Fachat
SPI means "Serial Peripheral Interface Bus" and is a very simple four-wire protocol. Some of the advantages are:
- Each signal is single direction, there are no bi-directional signals
- It is a synchronous bus and clock is controlled by a single source.
- It is byte-oriented
There are these four lines:
Signal | Direction | Description |
---|---|---|
/SEL | SPI Master -> SPI Slave | If low, the selected device is selected. A master may have multiple of those outputs, but a slave has only one input |
CLK | SPI Master -> SPI Slave | Clock for data transfers |
MOSI | SPI Master -> SPI Slave | Data from master to slave |
MISO | SPI Slave -> SPI Master | Data from slave to master |
SPI Modes
For this reason there are different possibilities:
- CPOL=0/1: base value of the clock. I.e. the level of the CLK signal when no data transfer is going on.
- CPHA=0/1: The transition of the clock (leading or trailing edge) on which the data is transferred
Mode | CPOL | CPHA |
---|---|---|
0 | 0 | 0 |
1 | 0 | 1 |
2 | 1 | 0 |
3 | 1 | 1 |
Links
- Wikipedia has some more detailled info
MMC-Card and SD-Cards are cheap means of getting large amounts of storage memory nowadays. And they are getting larger and cheaper every day. Those cards are based on flash memory and can be found in digital cameras, navigation systems, and many more.
Unfortunately the MMC- and SD-Card protocols are not free, however a certain amount of intelligence has been gathered and is available on the web:
as well as in datasheets for MMC or SD-Cards found on the producers homepages.MMC/SD SPI mode
Newer MMC and especially SD-Cards use a mode where more than a single bit is transferred per clock. In fact the cards have four data lines that are used in native mode. This mode is however more complicated. But, we are lucky, all cards still support the SPI mode, that they can enter upon startup when instructed to do so. And this is what the driver does.
One problem I had in the beginning was that the datasheets mentioned the data transfer on the rising edge of the clock, but not what clock level would be correct. By experimentation I found that MMCs and SD-Cards use mode 0.
SPI Links
- Wikipedia The wikipedia article on SPI.
- Daryl Rictor's SPI65 If you click on "65SPI" on the left navigation on that page, you find Daryl Rictor's 65SPI solution, a Xilinx 9572 CPLD-based SPI solution.
- SPI65/B Based on the specifications of Dary's solution, I have re-implemented it in VHDL with some modifications. See the descriptions after the link.
Disclaimer
Contents last modified 2012-01-04.
Return to Homepage
Last modified: 2024-02-03