STM32 SPI mode

Publisher:MengyunLatest update time:2018-12-26 Source: eefocusKeywords:STM32 Reading articles on mobile phones Scan QR code
Read articles on your mobile phone anytime, anywhere
  1. SPI protocol (Serial Peripheral Interface), also known as serial peripheral interface, is a high-speed full-duplex

Communication bus, it was proposed by Motorola, and the latest version is V04.01-2004.


  1. There are four SPI modes according to the different configurations of SPI clock polarity (CPOL) and clock phase (CPHA). 


  2. The clock polarity refers to when the SPI communication device is in idle state (it can also be considered that this is when the SPI communication starts, that is, the SS line

When CPOL=0, SCK is at a low level in idle state, and vice versa when CPOL=1. 


The clock phase refers to the moment of data sampling. When CPHA=0, the signal on the MOSI or MISO data line will be sampled on the odd edge of the SCK clock line. When CPHA=1, the data line is sampled on the even edge of SCK. 

Mode0: CPOL= 0, CPHA=0; 

Mode1: CPOL= 0, CPHA=1; 
Mode2: CPOL= 1, CPHA=0; 
Mode3: CPOL=1, CPHA= 1;


  1. SPI features of STM32: 


  2. The small capacity STM32 products have one SPI interface, the medium capacity ones have two, and the large capacity ones have three.

as follows: 

①Single transmission can be selected as 8 or 16 bits; 

② Baud rate pre-scaling factor (maximum is fpclk/2); 

③Clock polarity (CPOL) and phase (CPHA) can be programmed; 

④The transmission order of data sequence can be programmed, MSB first or LSB first; 

⑤ Dedicated send and receive flags that can trigger interrupts; 

⑥DMA can be used for data transfer operations.


Keywords:STM32 Reference address:STM32 SPI mode

Previous article:A collection of problems encountered during the use of STM
Next article:Summary of STM32 library function development

Recommended ReadingLatest update time:2024-11-16 15:49

STM32 several IO setting modes
Select IO mode in STM32 (1) Floating input_IN_FLOATING - floating input, can be used for KEY identification, RX (2) Pull-up input_IPU - IO internal pull-up resistor input (3) Pull-down input_IPD - IO internal pull-down resistor input (4) Analog input_AIN - use ADC analog input, or save power under low power consumptio
[Microcontroller]
Basic knowledge of STM32 USART
USART, also known as Universal Synchronous Asynchronous Receiver/Transmitter, uses a fractional bit rate generator to provide a wide range of bit rate options. The STM32F10x series chips all provide a powerful USART serial port, and the basic serial port functions can be implemented through hardware. USART has the fol
[Microcontroller]
STM32 study notes: FLASH emulation EEPROM
1. Brief Introduction STM32 itself does not have its own EEPROM, but STM32 has the In Application Programming (IAP) function, and its FLASH can be used as EEPROM. Different models of STM32 have different FLASH capacities, the smallest is only 16K bytes, and the largest is 1024K bytes. The FLASH capacity of the STM32
[Microcontroller]
STM32 study notes: FLASH emulation EEPROM
Design of FSMC interface driving TFT color screen based on STM32
  0 Introduction   With the continuous updating of electronic products, more and more display interfaces are being developed. Due to the high cost-effectiveness of TFT color screens, they are widely used as display screens in various electronic devices. At present, there are many solutions to drive TFT color screens
[Microcontroller]
Design of FSMC interface driving TFT color screen based on STM32
What should be paid attention to in cold start and hot start in STM32 based RTOS programming
Cold start and hot start are probably the knowledge that most people learn when they are learning 51. To sum up:         The so-called cold start is also known as power-on reset. After the cold start, the contents of the RAM inside and outside the chip are random, usually 0x00 or 0xFF; the hot start of the microcontro
[Microcontroller]
How does STM32 enter the interrupt service function xxx_IRQHandler
Today I was looking at the interrupt of stm32. For a moment, I didn't understand how the stm32 main function entered the interrupt function. According to the understanding of C programming, there would be a specific entry or something like that, but I didn't find the entry during the demo. Taking the serial port int
[Microcontroller]
Analyze the phenomenon of entering the send completion interrupt after initializing the STM32 serial port
Recently, I found a strange problem when debugging the STM32 serial port. After initializing serial port 1 and enabling the serial port send completion interrupt, the send completion interrupt was immediately entered. The same problem was discussed on the 21ic forum, but the perfume moderator did not explain the reason
[Microcontroller]
DMA configuration of STM32
DMA can be considered as connecting two "address" data channels. DMA shares the system bus and does not occupy the CPU, so it can achieve fast data transfer. Here we take DMA connection between memory (array) and serial port (USART1- DR) as an example.  1 void DMA_init(void)  2 {  4 RCC- AHBENR|=1 0; //Enable DMA1 c
[Microcontroller]
Latest Microcontroller Articles
  • Download from the Internet--ARM Getting Started Notes
    A brief introduction: From today on, the ARM notebook of the rookie is open, and it can be regarded as a place to store these notes. Why publish it? Maybe you are interested in it. In fact, the reason for these notes is ...
  • Learn ARM development(22)
    Turning off and on interrupts Interrupts are an efficient dialogue mechanism, but sometimes you don't want to interrupt the program while it is running. For example, when you are printing something, the program suddenly interrupts and another ...
  • Learn ARM development(21)
    First, declare the task pointer, because it will be used later. Task pointer volatile TASK_TCB* volatile g_pCurrentTask = NULL;volatile TASK_TCB* vol ...
  • Learn ARM development(20)
    With the previous Tick interrupt, the basic task switching conditions are ready. However, this "easterly" is also difficult to understand. Only through continuous practice can we understand it. ...
  • Learn ARM development(19)
    After many days of hard work, I finally got the interrupt working. But in order to allow RTOS to use timer interrupts, what kind of interrupts can be implemented in S3C44B0? There are two methods in S3C44B0. ...
  • Learn ARM development(14)
  • Learn ARM development(15)
  • Learn ARM development(16)
  • Learn ARM development(17)
Change More Related Popular Components

EEWorld
subscription
account

EEWorld
service
account

Automotive
development
circle

About Us Customer Service Contact Information Datasheet Sitemap LatestNews


Room 1530, 15th Floor, Building B, No.18 Zhongguancun Street, Haidian District, Beijing, Postal Code: 100190 China Telephone: 008610 8235 0740

Copyright © 2005-2024 EEWORLD.com.cn, Inc. All rights reserved 京ICP证060456号 京ICP备10001474号-1 电信业务审批[2006]字第258号函 京公网安备 11010802033920号