MBSP

Microcontroller Board Support Package

User Tools

Site Tools


spi_group

Differences

This shows you the differences between two versions of the page.

Link to this comparison view

spi_group [ 17.08.2025 05:40] – created larsspi_group [ 17.08.2025 05:52] (current) lars
Line 1: Line 1:
 +====== SPI ======
 +
 +Different variants exist. Usually SPI refers to the Motorola Serial Peripheral Interface. Other variants are the Texas Instruments Serial protocol (SSP) and the National Instruments Microwire.
 +
 +
 +===== Protocol =====
 +
 +Most significant bit first
 +
 +
 +===== Modes =====
 +There are 4 Modes. Defied by the two settings "clock polarity" CPOL and "clock phase" CPHA.
 +
 +"clock polarity" CPOL = 0:
 +  - Clock line is low when idle.
 +
 +"clock polarity" CPOL = 1:
 +  - Clock line is high when idle.
 +
 +"clock phase" CPHA = 0:
 +  - first data bit is output on /CS activating (going low).
 +  - data bits change when clock goes to idle level.
 +  - data bits are read when clock comes from idle level.
 +
 +"clock phase" CPHA = 1:
 +  - first data bit starts on first edge after /CS activates.
 +  - data bits change when clock comes from idle level.
 +  - data bits are read when clock goes to idle level.
 +  
 +^ mode ^ CPOL ^ CPHA ^ write bit                               ^ read bit        ^
 +| 0    | 0    | 0    | clock goes low, and when /CS activates  | clock goes high |
 +| 1    | 0    | 1    | clock goes high                         | clock goes low  |
 +| 2    | 1    | 0    | clock goes high, and when /CS activates | clock goes low  |
 +| 3    | 1    | 1    | clock goes low                          | clock goes high |
 +
 +
 ===== SPI group ===== ===== SPI group =====
  
Line 129: Line 165:
  
 **type**: int (Hz) **type**: int (Hz)
 +
 +
 +===== API =====
 +The part "signal_name" in the described functions will be replaced by the name of the signal. E.g. if your signal is called "audio" then the API function "signal_name_transfer" will become "audio_transfer".
 +
 +<code>
 +void signal_name_transfer(const uint8_t *data_send, 
 +                          const uint8_t *data_receive, 
 +                          const uint32_t length )</code>
 +Will send "length" bytes from the buffer "data_send" out on MOSI and will receive the same amount of bytes from MISO into the buffer "data_receive".
 +
  
spi_group.txt · Last modified: by lars