The "Serial Peripheral Interface" defines a 4-wire communication bus. Traditionally the 4 wires are named:
Many peripheral chips use a spi interface. MultiMediaCard (MMC) uses a spi interface.
If a microcontroller only needs to talk to 1 spi peripheral, the CS pin on that slave may be grounded unless the slave uses the CS rise or fall to trigger internal actions. e.g. some A2D chips will start a conversion on each CS fall. When CS is not used, the end of one command is immediatly followed by the start of the next. CS can be "faked" by adding an RC network from the clock pin. This will generate CS when the clock is active and drop it when the clock stops.
If a microcontroller needs to talk to multiple spi peripherals, there are 2 ways to set things up: "cascaded slaves" or "independent slaves".
"cascaded slaves" or "daisy-chained slaves": All the SCLKs are connected together. All the CS pins are connected together. The data flows out the microcontroller, through each peripheral in turn, and back to the microcontroller:
[uP MOSI] --> [MOSI device2 MISO] --> [MOSI device2 MISO] --> ... --> [MOSI deviceN MISO] --> [MISO uP].
"independent slaves": All the SCLKs are connected together. All the MISOs are connected together. All the MOSIs are connected together. The CS pin from each peripheral must be connected to a seperate pin on the microcontroller.
With a lot of spi peripherals, a lot of pins on the microcontroller can be tied up in CS selection in a "independent slave" setup. The "daisy-chained slave" setup uses a lot fewer pins. (Alternatively, you could switch to devices that support a different protocol such as I2C that does device selection using address bits on the data line, rather than CS pins.)
(There's a nice picture of "cascaded slaves" vs. "independent slaves" at http://mct.net/faq/spi.html
spi based I/O expanders.
Microchip PIC specific spi
spi Bug in LTC2400 analog to digital converter from Linear Technology
Hi; I have PS/2 keyboard, want to connect it to spi1 according to follow way:PS/2 spi1 CLK ----------- spiCLK DATA ---------- MOSI
connect SS pin of spi1 to low; spi1 worked on slave mode; initializtion of spi1:
- write '0x021A' to spi1 control/status register;
- setup interrupt handler;
- write '0' to bit 0 of the Port K register and bits 3-0 of the Port J register;
- write '0x08' to spi1 interrupt control/status register;
- write '0x00DFFFFF' to interrupt masked register;
- interrupt handler read data from 'spi1 receive data register';
but data read is different from keyboard scancode;
I want to know whether my connection is right; please give me a hint! best regards; seazjz 7.19
I doubt it is possible to connect a PS/2 keyboard to a spi bus. Have you read "The PS/2 Mouse/Keyboard Protocol" by Adam Chapweske http://computer-engineering.org/ps2protocol/ ? If you had, you would know that the *both* the clock *and* the data line are driven by *both* the PC *and* the keyboard (at different times, of course). That sounds to me much more like a I2C bus than a spi bus. Check /techref/microchip/i2c.htm for information on programming a PIC with the I2C protocol. Does that help? -- David Cary
/techref/io/serial/spis.htm It looks (at least to me)like a PS/2 keyboard can be connected to the spi bus of a microchip. The microchip output could drive the transistor to ground the data line (port switched to an input to turn off while letting the keyboard control the data). The CS pin could drive the transistor to drop the clock line to indicate to the keyboard to send a clock pulse and receive information from the host. As the buffers fill and empty it should be standard stuff.+
|file: /Techref/io/serial/spis.htm, 7KB, , updated: 2017/5/8 13:08, local time: 2018/10/22 08:30,
|©2018 These pages are served without commercial sponsorship. (No popup ads, etc...).Bandwidth abuse increases hosting cost forcing sponsorship or shutdown. This server aggressively defends against automated copying for any reason including offline viewing, duplication, etc... Please respect this requirement and DO NOT RIP THIS SITE. Questions?|
<A HREF="http://www.piclist.com/techref/io/serial/spis.htm?key=spi"> Serial Peripheral Interface</A>
|Did you find what you needed? "spi"|
PICList 2018 contributors:
o List host: MIT, Site host massmind.org, Top posters @20181022 RussellMc, Van Horn, David, Sean Breheny, David C Brown, Isaac M. Bavaresco, Neil, Bob Blick, John Gardner, Harold Hallikainen, AB Pearce - UKRI STFC,
* Page Editors: James Newton, David Cary, and YOU!
* Roman Black of Black Robotics donates from sales of Linistep stepper controller kits.
* Ashley Roll of Digital Nemesis donates from sales of RCL-1 RS232 to TTL converters.
* Monthly Subscribers: Gregg Rew. on-going support is MOST appreciated!
* Contributors: Richard Seriani, Sr.
Welcome to www.piclist.com!