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
4
votes
0 answers

Reset a MicroSd card whilst in Spi mode without a power cycle

I have an existing embedded system with an existing developed C code. Sometimes the microSD card can lock down giving responses outside of the scope of the existing system. I'm currently unsure why but suspect the handler in the existing system…
Chris599
  • 41
  • 5
4
votes
1 answer

SPI_IOC_MESSAGE(N) macro giving me fits

I'm having trouble getting a SPI program I'm working on to behave correctly and it seems to be some issue with the SPI_IOC_MESSAGE(N) macro. Here's sample code that DOESN'T work (ioctl returns EINVAL (22) ): std::vector tr;
Phil Mills
  • 63
  • 1
  • 4
4
votes
1 answer

How to handle two SPI devices in linux kernel with single SPI Platform Driver?

I have developed a SPI platform driver for a single SPI device.Which SPI device we are using,that configuration can be given in Device Tree.probe() function of SPI platform driver is called when name matching happens with name give in driver and the…
a.saurabh
  • 1,163
  • 10
  • 15
4
votes
2 answers

SPI pin inteference

I am using ATMEGA128 to communicate with another device. For this I am using SPI with ATMEGA128 as slave. I use SS, SCK and MOSI pins. The problem I am facing is that when I have to download program, I have to disconnect SPI pins. The ATMEGA128…
sujan_014
  • 516
  • 2
  • 8
  • 22
4
votes
1 answer

SPI timeout in Linux and C

I'm trying to implement a timeout for some hardware transmissions, to add security to a big project. I already implemented timeout using select for UART transmission, but I don't know how to add a timeout in a SPI transmission. This is my reading…
markmb
  • 852
  • 4
  • 12
  • 32
4
votes
3 answers

Linux kernel Controller as SPI slave

I am interested in working on SPI devices available in linux. I have a specific controller which supports SPI in both master and slave mode. I have to configure the SPI controller in slave mode. My question: Does the Linux frame work support SPI…
user3012531
  • 41
  • 1
  • 3
4
votes
2 answers

SPI: Linux driver model

I'm new with SPI; the Linux kernel provides an API for declaring SPI busses and devices, and managing them according to the standard Linux driver model. You can find the description of the struct spi_master here:…
Matteo M.
  • 65
  • 1
  • 3
4
votes
1 answer

Can I set up the priority of a workqueue?

Can I set up the priority of a workqueue? I am modifying the SPI kernel module "spidev" so it can communicate faster with my hardware. The external hardware is a CAN controller with a very small buffer, so I must read any incoming data quickly to…
Eduardo
  • 93
  • 2
  • 6
4
votes
0 answers

Using Boost.Asio with other serial devices like SPI

Boost.Asio uses a Proactor to magnificently handle I/O using a single thread. I used it with sockets and I love it. I see that there is a way to use the io_service of Boost.Asio (and the underlying Proactor) with serial ports (COMX devices on…
4
votes
2 answers

PIC32 SPI ISR not being called when RXIF flag set?

I'm using a PIC32MX795F512L SPI3 module in slave mode. My master is sending data over the SPI line but my slave's interrupt service routine is never being called. The RX interrupt flag is being set in hardware on the slave side and I can read the…
CodeFusionMobile
  • 14,812
  • 25
  • 102
  • 140
3
votes
5 answers

Any higher level protocol over serial port communication ?

We are running a course in robotics and Xbee is the most favorite communication protocol for the student. In last two years we helped them build around 62 various projects (40 more in pipeline). All most all the projects involve sending different…
Eastern Monk
  • 6,395
  • 8
  • 46
  • 61
3
votes
1 answer

Can't solve this synchronization SPI problem

So, I am integrating a MAX31865 temperature sensor in a NUCLEO-F103RB board using SPI communication. It doens't seem to be working well, since I just can't send a single Write Transmission: enter image description here I am just using this…
3
votes
1 answer

stm32 as SPI slave, full-duplex transmitting via circular DMA buffer: changes to MISO buffer not (completely) reflected in transfer

Created a project template via CubeMX: STM32G030 is SPI slave and uses circular DMA bufs for transfers. As SPI master I'm using an ESP32 running micropython. This, though, should be irrelevant, as I don't rely on its output but what the Logic…
daten
  • 131
  • 1
  • 1
  • 12
3
votes
0 answers

Reading Busy Flag of SSD1803 via SPI not working

The SSD1803 is a controller which is used to control an LCD-Display. I'm using SPI to communicate with the controller, which works fine for normal instructions: I can print text onto the display, clearing the display, storing my custom characters in…
puncher
  • 1,570
  • 4
  • 15
  • 38
3
votes
1 answer

STM32 SPI LL DMA Transmit

I have been trying to get SPI master transmit to work using DMA and STM32 LL drivers, on STM32G030C8. I did get the SPI to work with LL drivers without DMA, so I believe that at least my wiring is correct. What I have done: Set SPI to use DMA in…
Ou Tsei
  • 470
  • 7
  • 24