EasyManuals Logo

ST STM32F2 User Manual

ST STM32F2
1371 pages
To Next Page IconTo Next Page
To Next Page IconTo Next Page
To Previous Page IconTo Previous Page
To Previous Page IconTo Previous Page
Page #553 background imageLoading...
Page #553 background image
UM1940
HAL SPI Generic Driver
DocID028236 Rev 2
553/1371
Configure the SPIx interrupt priority
Enable the NVIC SPI IRQ handle
d. DMA Configuration if you need to use DMA process
Declare a DMA_HandleTypeDef handle structure for the transmit or receive
stream
Enable the DMAx clock
Configure the DMA handle parameters
Configure the DMA Tx or Rx stream
Associate the initialized hdma_tx handle to the hspi DMA Tx or Rx handle
Configure the priority and enable the NVIC for the transfer complete interrupt
on the DMA Tx or Rx stream
3. Program the Mode, BidirectionalMode , Data size, Baudrate Prescaler, NSS
management, Clock polarity and phase, FirstBit and CRC configuration in the hspi Init
structure.
4. Initialize the SPI registers by calling the HAL_SPI_Init() API:
This API configures also the low level Hardware GPIO, CLOCK, CORTEX...etc)
by calling the customized HAL_SPI_MspInit() API.
Circular mode restriction:
1. The DMA circular mode cannot be used when the SPI is configured in these modes:
a. Master 2Lines RxOnly
b. Master 1Line Rx
2. The CRC feature is not managed when the DMA circular mode is enabled
3. When the SPI DMA Pause/Stop features are used, we must use the following APIs the
HAL_SPI_DMAPause()/ HAL_SPI_DMAStop() only under the SPI callbacks
Master Receive mode restriction:
1. In Master unidirectional receive-only mode (MSTR =1, BIDIMODE=0, RXONLY=0) or
bidirectional receive mode (MSTR=1, BIDIMODE=1, BIDIOE=0), to ensure that the
SPI does not initiate a new transfer the following procedure has to be respected:
a. HAL_SPI_DeInit()
b. HAL_SPI_Init()
Using the HAL it is not possible to reach all supported SPI frequency with the different SPI
modes (refer to the device reference manual for the maximum SPI frequency reached with
data size 8bits/16bits, according to frequency used on APBx Peripheral Clock (fPCLK)
used by the SPI instance).
43.2.2 Initialization and de-initialization functions
This subsection provides a set of functions allowing to initialize and de-initialize the SPIx
peripheral:
User must implement HAL_SPI_MspInit() function in which he configures all related
peripherals resources (CLOCK, GPIO, DMA, IT and NVIC ).
Call the function HAL_SPI_Init() to configure the selected device with the selected
configuration:
Mode
Direction
Data Size
Clock Polarity and Phase
NSS Management
BaudRate Prescaler
FirstBit
TIMode
CRC Calculation

Table of Contents

Questions and Answers:

Question and Answer IconNeed help?

Do you have a question about the ST STM32F2 and is the answer not in the manual?

ST STM32F2 Specifications

General IconGeneral
BrandST
ModelSTM32F2
CategoryMicrocontrollers
LanguageEnglish

Related product manuals