Questions tagged [spi]

Serial Peripheral Interface. Allows full-duplex serial communication from a master device to one or more slave devices arranged on a bus. Sometimes referred to as a 4-wire bus.

SPI (Serial Peripheral Interface) is used to communicate bi-directionally with other peripherals. The SPI interface normally has the following signals:

  • SCK - serial clock, sometimes called CLK - this provides the clock data which controls the rate of data transfer
  • MOSI - Master Out, Slave In, sometimes called DO (Data Out) - this is the data from the master to the slave
  • MISO - Master In, Slave Out, sometimes called DI (Data In) - this is the data from the slave to the master
  • SS - Slave Select - when asserted the slave knows it is being communicated with. When SS is not asserted the slave keeps all signals at high-impedance, so other devices can use the same SCK/MOSI/MISO lines.

The signals SCK/MOSI/SS are outputs on the master end. The MISO signal is an output on the slave side, if SS is asserted.

The signals SCK/MOSI/MISO can be shared between multiple peripheral devices. The "active" one at a particular moment is the one which has SS asserted.


Some peripherals (eg. LED strips, output shift registers) are one-direction only. In that case the MISO signal is not used.


References

501 questions
6
votes
3 answers

When is SPI.beginTransaction required?

I have been gradually converting many devices from i2c to spi for various reasons. I noticed in tutorials like this from arduino.cc that SPI.beginTransaction is explicitly called out. Then they link to examples such as this and this where they…
Matt
  • 205
  • 3
  • 9
6
votes
4 answers

How do I transfer more than 1 byte at once via SPI bus?

I have an AD5685R DAC that I am trying to communicate with over SPI. Per the datasheet, ...These [24] bits are transferred to the input register on the 24 falling edges of SCLK and are updated on the rising edge of /SYNC where /SYNC is used as…
Dang Khoa
  • 173
  • 1
  • 1
  • 6
5
votes
1 answer

ATMEGA328 SPI MCP2515 - SPI communication freezes at certain point

I got 2 boards with an ATMEGA328 microcontroller and MCP2515 CAN Controller and I'm trying to get them communicate with each other. To shortcut the programming a little bit I'm using the Sparkfun CAN BUS Library, but I am not using ther…
KarlKarlsom
  • 176
  • 2
  • 12
3
votes
1 answer

Arduino UNO SPI Serial Clock (Pin 13 SCK) gives no output, but Blink Example (Pin 13 LED) works

I was attempting to use an SPI library and DAC device (Library AD57X4) for the first time, when I realized that the Arduino UNO Pin 13 was not outputting a clock signal (something I expected it to do). Using a serial analyzer I can sample at 16MHz,…
user391339
  • 165
  • 1
  • 7
3
votes
4 answers

Creating variable inside if statement (conditional signed vs unsigned int)

I have an SPI chip that I would like to read out with an Arduino. Some of the registers are signed int others are unsigned int. I am writing a function to read any register. A simplified version: readRegister(byte thisRegister, char type) { …
Sebastian
  • 133
  • 3
3
votes
1 answer

Why isn't there bus contention on the MISO line during SPI-based programming?

Consider this image from sparkfun: Let's say I have this setup, a master and n slaves, plus a programmer connected to the SPI lines. When I program the master (Arduino), the Arduino is reset. This means that all the data pins go low. Since SS is…
Ana
  • 480
  • 2
  • 7
  • 13
2
votes
1 answer

Slaving multiple Arduinos via SPI

I am attempting to use SPI communication between a Master Arduino Mega 2560, and standalone Slave Arduino Unos (4, to be exact). The intention is for the Unos to do some trivial work and produce one byte of data that the Master will take from it,…
2
votes
1 answer

Is there any standard for colors of Serial Peripheral Interface wires?

Having DuPont cables like on the picture... ... and the RFID RC522 reader with colored wires as found in one of the tutorials. I know that copper is the same inside of the wires. Anyway, is there any standard or de-facto standard of assigning…
pepr
  • 147
  • 6
2
votes
1 answer

Is it possible to synchronize two SPI busses to send data out in parallel on the same clock signal?

We're working with these very odd driver chips which are sort of like shift registers except rather than latch the data at the end, the latch needs to happen over the last 'n' clock cycles in parallel with the data being shifted out. Depending on…
2
votes
2 answers

Arduino based SPI programming of LT1257 not working

I am trying to talk to an LT1257 using an Arduino Nano Atmega328. I am not using the default slave select pin. I am using pin 5 as chip select for the DAC. The LT1257 data sheet shows this timing diagram. What I inferred from this diagram is that…
user1155386
  • 131
  • 3
2
votes
2 answers

Can the SPI pins of an Arduino be separated from SPI?

Are the SPI pins on the ICSP header of an Arduino Uno "separable" from the correspondent I/O pins - when one chooses to the use the ICSP header can the corresponding I/O pins be used for something else?
joaocandre
  • 143
  • 6
2
votes
2 answers

STPM10 using Arduino SPI communication

I am working with STPM10 energy metering chip (evaluation board) and I want to read the data from 8 internal registers of the chip each containing 32 bits. The datasheet of the STPM10 chip suggested to have a simplex synchronous SPI where the MOSI…
Lorenz Ardiente
  • 31
  • 1
  • 1
  • 4
2
votes
1 answer

util/delay.h from arduino _delay_ms not delaying in accurate time with my hardware configuration

I have configured my arduino as a flash programmer and i'm sending data to an atmega328P. It is actually working and the data is send to my atmega328. But what is strange that the _delay_ms from from the Arduino library is not delaying in accurate…
Mr Bonjour
1
vote
2 answers

Can Arduino UNO/MEGA master assert SPI SS LOW on multiple slaves at once if Full Duplex is unnecessary?

I have a computer talking serially to an UNO SPI Master and, beyond it, multiple MEGA Slaves. The slaves never talk back to the master. I understand it is normal and correct to assert SS LOW to select one slave at a time, such that the master…
1
vote
1 answer

Sending multiple data with SPI interface monitored by an Osciloscope

I have multiple 32-bit data stored in an array, and I want to sequentially send them by SPI interface. I want to check that my code is correctly sending data by SPI interface, so I upload the code and connect my Linkit7697 to an oscilloscope. The…
jcwu
  • 11
  • 2
1
2 3