yahboom
HomeLearn
Solution
Blog
Online Store
About Us
EN/中文
STM32-BoardCar📖
0. Get started quickly
  • 0.ReadMe
  • 1. Installation Instructions
  • 2. Version configuration
  • 3. Smart car installation video
  • 4. Precautions for use
1. Introduction to STM32 development board
  • 1. Learn about STM32
  • 2. Introduction to STM32 development board
  • 3. Development board pin assignment
  • 4. Introduction to HAL library and LL library
2. Setting up and using the development environment
  • 1. Common development tools
  • 2. STM32CubeMX Install - Use
  • 3. STM32CubeIDE Install - Use
  • 4. Common Driver Installation
  • 5. Program download and simulation
  • 6. Engineering experience and migration
3. Development board basic tutorial
  • 1. RGB searchlight (GPIO)
  • 2. Buzzer control (GPIO)
  • 3. Button control (EXTI)
  • 4. Serial communication (UASRT)
  • 5. Voltage detection (ADC)
  • 6. Internal temperature sensor(ADC)
  • 7. Independent watchdog(IWDG)
  • 8. Window watchdog(WWDG)
  • 9. Basic timer (TIM6)
  • 10. Universal Timer (TIM3)
  • 11. Advanced timers (TIM1)
  • 12. I2C Communication (IIC)
  • 13. Off-chip Flash (SPI)
  • 14. On-chip Flash (Flash)
  • 15. DMA:USART
  • 16. DMA:SPI
  • 17. DMA:I2C
  • 18. USB communication
  • 19. USB analog U disk
  • 20. FreeRTOS
4. Car expansion tutorial
  • 1. Servo control
  • 2. Basic use of ultrasonic steering gear gimbal
  • 3. Motor control
  • 4. OLED display light sensitivity value
  • 5. Infrared sensor
  • 6. Four-way tracking module
  • 7. Infrared remote control
  • 8. Ultrasonic ranging
  • 9. PS2 controller test
  • 10.K230 Vision Module
  • 11.AI voice interaction integration module
5. Robot car tutorials
  • 1. Car line patrol
  • 2. Ultrasonic follow
  • 3. Ultrasonic obstacle avoidance
  • 4. Ultrasonic obstacle avoidance (servo gimbal version)
  • 5. Infrared sensor obstacle avoidance
  • 6. Infrared remote control
  • 7. PS2 handle remote control
  • 8.K230 face tracking on PTZ
  • 9.K230 color tracking
  • 10.K230 Color Line Patrol
  • 11.K230 QR code command
  • 12.K230 machine code tracking
  • 13.K230 road sign indication action (voice)
  • 14.K230 color response (voice)
  • 15.K230 gesture control (voice)
  • 16.K230 Rock-Paper-Scissors Game (Voice)
6. Operation video
  • 1-How to install STM32CubeIDE software
  • 2-How to create Demo project
  • 3-How to download code into STM32 robot car
  • 4-How to open and compile a code file for STM32
  • 5-About IR control and Charge battery
Download
  • Code
  • SCH
  • Software File
  • STM32 Chip DataSheet
  • Installation manual
Download ZIP

Welcome to STM32-BoardCar repository

15. DMA:USART

DMA:USART

DMA:USART1、software-hardware2、Brief principle2.1、Hardware schematic diagram2.2、Physical connection diagram3.3、Principle of control3、Engineering configuration3.1、Notes3.2、Pin configuration4、Main Function4.1、User function4.2、LL library function analysis5、Experimental phenomenon

This tutorial demonstrates Serial (USART1) communication via DMA

1、software-hardware

  • STM32F103CubeIDE

  • STM32 robot expansion board

    USART1, DMA: chip internal peripheral

  • Type-C cable or ST-Link

    Download or simulate the program of the development board

2、Brief principle

2.1、Hardware schematic diagram

The schematic only shows the serial interface used in the tutorial (USART1)

image-20231021224018847

2.2、Physical connection diagram

image-20231021224208843

3.3、Principle of control

  • USART1

The knowledge related to serial port will not be introduced, you can see before [Chapter 3:3.4 Serial communication]

  • DMA(Direct Memory Access)

STM32F103ZET6 has a total of two DMA controllers, DMA1 has 7 channels, DMA2 has 5 channels;

It is used for high-speed data transfer between peripheral equipment and memory and between memory and memory.

DMA features

The initialization and start of DMA are completed by the CPU, and the transfer process is executed by the DMA controller without the participation of the CPU, so that the CPU resources are saved to do other operations

DMA1 requests per channel

image-20231021232455032

DMA2 requests per channel

image-20231021232601769

DMA1 channels 4 and 5 are used in this tutorial

3、Engineering configuration

Project Configuration: Prompts for configuration options in the STM32CubeIDE project configuration process

3.1、Notes

Omitted project configuration: New project, chip selection, project configuration, SYS for pin configuration, RCC configuration, clock configuration, and project configuration content

The project configuration part, which is not omitted, is the key point to configure in this tutorial.

Please refer to [2. Development environment construction and use: STM32CubeIDE installation and use] to understand how to configure the omitted parts of the project.

3.2、Pin configuration

  • Configure the specified pin function

You can directly select the corresponding pin number in the pin view, and the corresponding option will appear when the mouse is left clicked

00902899a35abea861844a199a45530e

  • USART1

image-20231021233759254

image-20231021233902552

image-20231021234418399

  • NVIC

    NVIC can modify interrupt priority

image-20231021234548069

  • Advanced Settings

image-20231030164545043

  • Generating code

image-20231020123054441

4、Main Function

This section mainly introduces the functional code written by users. Detailed code can be opened by yourself in the project file we provide, and enter the Bsp folder to view the source code. .

4.1、User function

function:USART1_DataByte

Function prototypesvoid USART1_DataByte(uint8_t data_byte)
Functional DescriptionSending a single byte
Input parametersdata_byte:Data to be sent
Return valueNone
TipsDefine the DMA_USART macro to switch between DMA transfer and USART directly

function:USART1_DataString

Function prototypesvoid USART1_DataString(uint8_t *data_str, uint16_t datasize)
Functional DescriptionSending strings
Input parameters1data_str:The first address to send data to
Input parameters2datasize:Data size
Return valueNone
TipsDefine the DMA_USART macro to switch between DMA transfer and USART directly

4.2、LL library function analysis

LL library functions that have been covered in the previous tutorial will not be covered in the tutorial

xxxxxxxxxx
If you want to find the HAL library and LL library function analysis involved in the entire tutorial, you can view the documents in the folder [8. STM32 Manual: STM32F1_HAL Library and LL Library_User Manual]

function:LL_DMA_SetDataTransferDirection

Function prototypesvoid LL_DMA_SetDataTransferDirection(DMA_TypeDef *DMAx, uint32_t Channel, uint32_t Direction)
Functional DescriptionSet the direction of data transmission
Input parameters1DMAx:DMA handle address
Input parameters2Channel:DMA channel number in the range 0 to 7
Input parameters3Direction:Direction of data transmission
Return valueNone

function:LL_DMA_SetChannelPriorityLevel

Function prototypesvoid LL_DMA_SetChannelPriorityLevel(DMA_TypeDef *DMAx, uint32_t Channel, uint32_t Priority)
Functional DescriptionSet the priority of the DMA channel
Input parameters1DMAx:DMA handle address
Input parameters2Channel:DMA channel number in the range 0 to 7
Input parameters3Priority:priority
Return valueNone

function:LL_DMA_SetMode

Function prototypesvoid LL_DMA_SetMode(DMA_TypeDef *DMAx, uint32_t Channel, uint32_t Mode)
Functional DescriptionSet DMA working mode
Input parameters1DMAx:DMA handle address
Input parameters2Channel:DMA channel number in the range 0 to 7
Input parameters3Mode:Mode of work
Return valueNone

function:LL_DMA_SetPeriphIncMode

Function prototypesvoid LL_DMA_SetPeriphIncMode
(DMA_TypeDef *DMAx, uint32_t Channel, uint32_t PeriphOrM2MSrcIncMode)
Functional DescriptionSet DMA peripheral delta mode
Input parameters1DMAx:DMA handle address
Input parameters2Channel:DMA channel number in the range 0 to 7
Input parameters3PeriphOrM2MSrcIncMode:Incremental mode selection
Return valueNone

function:LL_DMA_SetMemoryIncMode

Function prototypesvoid LL_DMA_SetMemoryIncMode
(DMA_TypeDef *DMAx, uint32_t Channel, uint32_t MemoryOrM2MDstIncMode)
Functional DescriptionSet DMA memory increment mode
Input parameters1DMAx:DMA handle address
Input parameters2Channel:DMA channel number in the range 0 to 7
Input parameters3MemoryOrM2MDstIncMode:Incremental mode selection
Return valueNone

function:LL_DMA_SetPeriphSize

Function prototypesvoid LL_DMA_SetPeriphSize(DMA_TypeDef *DMAx, uint32_t Channel, uint32_t PeriphOrM2MSrcDataSize)
Functional DescriptionSet the peripheral data size
Input parameters1DMAx:DMA handle address
Input parameters2Channel:DMA channel number in the range 0 to 7
Input parameters3PeriphOrM2MSrcDataSize:Data size
Return valueNone

function:LL_DMA_SetMemorySize

Function prototypesvoid LL_DMA_SetMemorySize
(DMA_TypeDef *DMAx, uint32_t Channel, uint32_t MemoryOrM2MDstDataSize)
Functional DescriptionSet the memory data size
Input parameters1DMAx:DMA handle address
Input parameters2Channel:DMA channel number in the range 0 to 7
Input parameters3MemoryOrM2MDstDataSize:Data size
Return valueNone

function:LL_DMA_SetMemoryAddress

Function prototypesvoid LL_DMA_SetMemoryAddress(DMA_TypeDef *DMAx, uint32_t Channel, uint32_t MemoryAddress)
Functional DescriptionSet the DMA memory address
Input parameters1DMAx:DMA handle address
Input parameters2Channel:DMA channel number in the range 0 to 7
Input parameters3MemoryAddress:Memory address
Return valueNone

function:LL_DMA_SetPeriphAddress

Function prototypesvoid LL_DMA_SetPeriphAddress(DMA_TypeDef *DMAx, uint32_t Channel, uint32_t PeriphAddress)
Functional DescriptionSet the DMA peripheral address
Input parameters1DMAx:DMA handle address
Input parameters2Channel:DMA channel number in the range 0 to 7
Input parameters3PeriphAddress:Peripheral device address
Return valueNone

function:LL_DMA_SetDataLength

Function prototypesvoid LL_DMA_SetDataLength(DMA_TypeDef *DMAx, uint32_t Channel, uint32_t NbData)
Functional DescriptionSet the length of DMA transfer data
Input parameters1DMAx:DMA handle address
Input parameters2Channel:DMA channel number in the range 0 to 7
Input parameters3NbData:Data length
Return valueNone

function:LL_DMA_EnableChannel

Function prototypesvoid LL_DMA_EnableChannel(DMA_TypeDef *DMAx, uint32_t Channel)
Functional DescriptionEnable DMA channels
Input parameters1DMAx:DMA handle address
Input parameters2Channel:DMA channel number in the range 0 to 7
Return valueNone

function:LL_DMA_DisableChannel

Function prototypesvoid LL_DMA_DisableChannel(DMA_TypeDef *DMAx, uint32_t Channel)
Functional DescriptionClosing the DMA channel
Input parameters1DMAx:DMA handle address
Input parameters2Channel:DMA channel number in the range 0 to 7
Return valueNone

function:LL_USART_EnableDMAReq_RX

Function prototypesvoid LL_USART_EnableDMAReq_RX(USART_TypeDef *USARTx)
Functional DescriptionEnable DMA serial port reception
Input parametersUSARTx:USART handle address
Return valueNone

function:LL_USART_EnableDMAReq_TX

Function prototypesvoid LL_USART_EnableDMAReq_TX(USART_TypeDef *USARTx)
Functional DescriptionEnable DMA serial port sending
Input parametersUSARTx:USART handle address
Return valueNone

5、Experimental phenomenon

After downloading the program successfully, press the RESET button of the development board to open the serial debugging assistant to observe the phenomenon

xxxxxxxxxx
For program download, please refer to [2. Development environment construction and use: program download and simulation]

phenomenon:

Press RESET button, serial debugging assistant will print USRT+DMA Class! Character;

Then through the serial port debug assistant to send what information will print the corresponding information

image-20231102194345477

On-chip Flash (Flash)
DMA:SPI

COMPANY

  • About us
  • Team Style
  • Blog

LEARNING & EXPLORATION

  • Tutorials
  • Edge AI hardware
  • Educational robots
  • Embedded intelligent hardware

WHERE TO BUY

  • Yahboom Online Store
  • Amazon
  • Alibaba
  • AliExpress
  • Mercado

TECHNOLOGY SUPPORT

  • Email: support@yahboom.com

BE A DISTRIBUTOR

  • Email: sales@yahboom.com
QR Code

Copyright © 2017-2026 Yahboom. All Rights Reserved.

EN/中文