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
3
votes
1 answer

SPI with NXP CLRC663 : read only 0xFF

I am currently working on an SPI communication between an NXP LPC55S06 processor (from the LPC55S06-EVK demoboard) and an NXP CLRC663. I integrated the NXP NFC library to initialize the CLRC663 and configured the SPI pinouts in the .mex file. I have…
Martin Denion
  • 352
  • 1
  • 3
  • 22
3
votes
1 answer

Esp32 Micropython Max31865 Spi connection and data read

I need to read temperature data with using MAX31865 SPI communication. First of all, I tried to read 4 byte data: import machine import ubinascii spi = machine.SPI(1, baudrate=5000000, polarity=0, phase=0) #baudrate controls the speed of the clock…
noobinmath
  • 175
  • 2
  • 12
3
votes
1 answer

How to exploit double buffering for reading digital inputs state?

I have following situation. I have a microcontroller which communicates with two external I/O expander chips via one SPI peripheral. Each of the chips has eight digital inputs and is equiped with the latch input which ensures that both bytes of the…
3
votes
2 answers

Raspberry pi pico rfid rc522 (Micropython)

I want to read data from mfrc522 (Iduino RFID-rc522) card reader using my RPi Pico but I don't know how to. I was trying to use mfrc522.py MicroPython library made for this purpose. Reader is communicating with Pi over SPI and I connected it to…
HeyNobody
  • 33
  • 1
  • 4
3
votes
1 answer

STM32 SPI Driver Receiving Data Always 0

I'm trying to write an SPI driver using the stm32 LL libraries (for the STML4 system). I'm testing the SPI driver by writing 2 bytes to the MOSI line and listen for 1 byte on the MISO line. Using an oscilloscope I was able to verify the 2 bytes were…
3
votes
1 answer

SDHC card SPI initialisation

I'm working on an embedded system that currently only supports SDSC v1 cards. As it's getting harder and harder to find cards less than 2 GB, I'm trying to add support for SDHC cards. The communication with the card is done via the SPI bus. So here…
lang2
  • 11,433
  • 18
  • 83
  • 133
3
votes
1 answer

Interview question - How to continuosly read a buffer without losing data

I am an embedded engineer, with not much experience. I was at an interview and I was asked a question, which I guess is not new and already has answers: You have a peripheral which is constantly receiving input from external world, the peripheral…
Naveen
  • 73
  • 6
3
votes
2 answers

How to read_single_block from SD card using SPI mode (getting weird behavior as of yet)?

When I issue cmd17 with address (0x00000000) to my card from PIC-18F4520 on SPI bus, I get a correct return R1 token from the command issue. Then, after a few loops checking, I get a 0xFE marker returned from my issuing SPI_Put_Char(0xFF). Data…
The Dick Chuck
  • 31
  • 1
  • 1
  • 4
3
votes
1 answer

STM32: Receiving SPI data with DMA - always wrong number of bytes in Rx buffer

With an STM32F764 I want to receive 33 bytes from 11 daisy-chained 24 bit ADCs via SPI in read-only mode. The received data looks okay but there are 37 to 39 bytes in the buffer. Also with other byte numbers I receive 4 to 6 bytes more than…
JanBurg
  • 31
  • 3
3
votes
1 answer

SPI driver, searching where to start

I'm new with Android developpemnent but I want to write a SPI driver to connect a SPI IC and then an Android application to send and receive data from and to the IC. From there, I don't really know where to create the driver (and what it should…
fleclerc
  • 43
  • 5
3
votes
1 answer

STM32 + SD card (FATFS and SPI) + physical connection + FR_NOT_READY

I am new to the world of stm and STM32CubeMX. So far, I was able to successfully implement SPI and I2C on a temperature sensor. Now I try to write data to an SD card, unfortunately so far without success. As a microcontroller I use the STM32L073RZT6…
Till
  • 31
  • 1
  • 4
3
votes
2 answers

SPI initializing in Atmel studio

im trying to use my Micro OLED Sparkfun display (here is the datasheet enter link description here) but i have a problem about code. Maybe is the problem in code because im working first time with SPI in Atmel so if would be somebody so nice and…
user10400521
3
votes
0 answers

Event handler on GpioPin causes garbage collector to freeze application

I'm writing UWP application in C# for Windows 10 IoT Core on Raspberry Pi 3B, which is supposed to interact with TI ADS1601 16-bit ADC. In order to communicate with this chip, I have to bitbang simple SPI-like serial communication protocol, and…
3
votes
2 answers

Receiving SPI data via DMA on PIC32

I know that this topic (DMA & SPI) has already been talked about on numerous threads in the microchip forum, actually i've read all the 15 pages in result of the search with keyword "dma" and read all the topics about dma & spi. And I am still…
Yann Sionneau
  • 31
  • 1
  • 1
  • 2
3
votes
1 answer

Reading values of SPI data register of STM32 MCU

There are quite a few similar questions, but none seem to have quite the same issue. I am connecting an STML4 MCU to a 6-axis sensor (LSM6DS3). I have successfully implemented everything in I2C, but would like the extra speed of SPI (and DMA, if I…
TrivialCase
  • 1,060
  • 2
  • 14
  • 27