If we have two or more SPI devices on the bus, the wiring would resemble the following: In other words, to communicate with a particular SPI device on the bus, we set the SS line to that device to LOW, then communicate with it, then set the line back to HIGH. This can only happen when the SS line is set to LOW. For example, for one device the wiring would be:ĭata travels back and forth along the MOSI and MISO lines between our Arduino and the SPI device. You can control one or more devices with the SPI bus. If you are using an Arduino Leonardo, the SPI pins are on the ICSP header pins. You can use other digital pins, but 10 is generally the default as it is next to the other SPI pins Īrduino Mega users – MISO is 50, MOSI is 51, SCK is 52 and SS is usually 53. On our Arduino Uno and compatible boards the pins used are: Within these tutorials we consider the Arduino board to be the master and the SPI devices to be slaves. Each SPI device needs a unique SS line back to the Arduino This line tells the device on the bus we wish to communicate with it. This line carries data from the SPI-controlled device(s) back to the Arduino This line carries data from our Arduino to the SPI-controlled device(s) To allow synchronous data transmission, the SPI bus uses four wires. It is a synchronous serial data bus – data can travel in both directions at the same time, as opposed to (for example) the I2C bus that cannot do so. SPI is an acronym for “Serial Peripheral Interface”. In this tutorial things will be kept as simple as possible.īut first of all, what is it? And some theory… The SPI bus may seem to be a complex interface to master, however with some brief study of this explanation and practical examples you will soon become a bus master! To do this we will learn the necessary theory, and then apply it by controlling a variety of devices. This is the first of two chapters in which we are going to start investigating the SPI data bus, and how we can control devices using it with our Arduino systems.
0 Comments
Leave a Reply. |
AuthorWrite something about yourself. No need to be fancy, just an overview. ArchivesCategories |