Questions tagged [spi]

Serial Peripheral Interface (SPI) is a serial, synchronous bus commonly used in embedded systems. It is most often used for communication between a microcontroller and peripheral hardware such as memories, shift registers, sensors, displays etc, but can also be used for MCU to MCU communication.

Serial Peripheral Interface (SPI) is a serial, synchronous, full duplex bus commonly used in embedded systems. It is most often used for communication between a microcontroller and peripheral hardware such as memories, shift registers, sensors, displays etc, but can also be used for MCU to MCU communication.

SPI was originally developed by Motorola as a hardware peripheral in their microcontroller products. It has become an industry de facto standard and pretty much every MCU made today has got hardware support for SPI. It is however possible to implement SPI without hardware support: a software-controlled SPI communication can be created by using only general-purpose I/O pins, so called "bit-banging".

SPI can be used either as a point-to-point communication between one node called master and another called slave, or as a system with one master and multiple slaves. The latter can be achieved by using either multiplexer circuitry on the slave select line or a so-called daisy chain implementation.

SPI consists of 4 digital signals:

  • MOSI, Master Output Slave Input. Data line for transmission from the master to the slave.
  • MISO, Master Input Slave Output. Data line for transmission from the slave to the master.
  • SCLK, Serial Clock (sometimes called SCK or just CLK)). The clock used for all synchronization, generated by the master.
  • SS, Slave Select. Chip select for the slave(s), active low signal.

Tag usage

Use this tag in combination with and the tag for the MCU being used, if applicable. For hardware-related questions, use https://electronics.stackexchange.com.


References

1385 questions
8
votes
2 answers

Spidev do not write/read simultaneously using ioctl

I hope to find some help even if this issue might be more hardware than software related (we'll see). I'm working on a custom board based on Freescales P1021 processor (ppc, e500v2 core). A external PCB will be connected and could be configured by…
stede
  • 355
  • 2
  • 4
  • 9
7
votes
2 answers

SPI + JDK 9 + module-info.java

I am experimenting with SPI on JDK 9. Entire example works on JDK 9 without "module-info.java". After adding "module-info.java" ServiceLocator is not finding implementing class. I am confused and I cannot find working SPI example in modularized JDK…
6
votes
2 answers

Can I select() on a /dev/spidev file descriptor?

I'm maintaining some userspace code that talks to a FPGA via SPI. Right now it's polling to see if there's data to act on, which I'm not thrilled about. The (heavily-simplified) structure of the comm thread looks like this: int spi_fd; void…
laughingcoyote
  • 259
  • 2
  • 9
6
votes
4 answers

How do you handle large data transfers on very memory constrained, embedded systems?

I have a microcontroller that must download a large file from a PC serial port (115200 baud) and write it to serial flash memory over SPI (~2 MHz). The flash writes must be in 256 byte blocks preceded by a write command and page address. The total…
Judge Maygarden
  • 26,961
  • 9
  • 82
  • 99
6
votes
5 answers

What are the disadvantages of bit banging SPI/I2C in embedded applications

I have come to understand that bit banging is horrible practice when it comes to SPI/I2C over GPIO. Why so?
anujdeshpande
  • 313
  • 1
  • 5
  • 11
5
votes
2 answers

U-Boot 2020.04: Probing SPI flash fails - Invalid bus 0 (err=-19)

I'm just compiled U-Boot 2020.04 for a PINE64 ROCK64 media board. It compiles fine without errors. But I run into an issue when I try to probe the SPI flash. The output from U-Boot command line: => sf probe Invalid bus 0 (err=-19) Failed to…
user10008009
5
votes
2 answers

STM32 SPI Slow Compute

I'm using a STM32F4 and its SPI to talk to a 74HC595 like in this tutorial. Difference is for starters I'm using the non-DMA version for simplicity. I used STMCubeMX to configure SPI and GPIO Issue is: I'm not getting the latch PIN, that I set to…
Julian
  • 915
  • 8
  • 24
5
votes
3 answers

How to decrease SPI overhead time for STM32L4 HAL library

I am using a STM32L476RG board and HAL SPI functions: HAL_SPI_Transmit(&hspi2, &ReadAddr, 1, HAL_MAX_DELAY); HAL_SPI_Receive(&hspi2, pBuffer, 4, HAL_MAX_DELAY); I need to receive data from accelerometer's buffer with maximum speed and I have a…
awyzlin
  • 73
  • 1
  • 5
5
votes
2 answers

How to enable and use SPI on the BeagleBoneBlack

I have a BeagleBoneBlack Wireless and I would like to use SPI (and I2C). I am finding it very difficult to get definitive instructions on how to set up and use SPI on the BBB. Firstly, it is not clear to me what the default configuration of the BBB…
P Mendham
  • 241
  • 5
  • 12
5
votes
3 answers

How do I flash an LED, using libftdi v0.18?

It's a FT2232D chip, and the LED is connected to BDBUS6. The library is less documented than I might like (better than FTDI's own library though, which doesn't even work on modern kernels), the only example code I can find that does this uses a…
John O
  • 4,863
  • 8
  • 45
  • 78
5
votes
1 answer

SPI Hardware interface to z80

I am attempting to make a retro computer using a z80 and ideally would like to give it the ability to boot from an SD card. I am 100% set on using a z80 and do not want to use a microcontroller with an internal SPI hardware interface. I want to…
KeatonB
  • 213
  • 2
  • 10
5
votes
1 answer

Sparkfun SC16IS750 does not work on Raspberry Pi

I'm connecting a SC16IS750 spi-2-uart bridge to the Raspberry Pi 2 in order to increase the number of uart ports. The product is a breakout board made by Sparkfun (https://www.sparkfun.com/products/9981), utilizing the SC16IS750 chip…
JZYL
  • 211
  • 1
  • 8
5
votes
1 answer

SPI Slave setup on STM32F4 board

I am trying to communicate between two STM32F4 discovery boards via SPI in Master & Slave configuration. I already have the code for the master but I am a bit confused on the changes I need to make on the SPI initialisation for the slave. I would…
user2253922
  • 125
  • 1
  • 4
  • 10
5
votes
3 answers

Arduino Nano: is SPI supported?

Can SPI hardware on the Arduino Nano be used? On the Nano page it says: SPI: 10 (SS), 11 (MOSI), 12 (MISO), 13 (SCK). These pins support SPI communication, which, although provided by the underlying hardware, is not currently included in the…
Jodes
  • 14,118
  • 26
  • 97
  • 156
4
votes
1 answer

SDHC SPI write issues

I've been trying to do an SD card interface with the LPC1766 SPI peripheral for a while and right now I'm stuck in a problem that I couldn't find the answer anywhere. The problem is: SDHC cards are not responding to write and read commands as…
Martini
  • 41
  • 2
1
2
3
92 93