Udemy
    •  
    •  
    •  
    •  
    •  
    •  
    •  
    •  
Turn what you know into an opportunity and reach millions around the world.
Learn More
Your cart is empty.
Keep shopping
How To Use STM32's UART with DMA
Rating: 4.0 out of 5(34 ratings)
1,079 students

How To Use STM32's UART with DMA

Module 1: Creating convenient library for transmitting and receiving data using STM32’s UART
Created byGeorgy Moshkin
Last updated 9/2023
English

What you'll learn

  • Sending and receiving single bytes
  • Making reliable DMA-based serial library
  • Working with multiple UART ports
  • Adding RS-485 support

Course content

1 section12 lectures30m total length
  • Introduction1:02
  • The right way1:51
  • Configuring UART ports1:16
  • Simple receive and transmit experiment3:07
  • Receiving single byte3:59
  • Calculating available unprocessed bytes count2:07
  • Receiving multiple bytes0:53
  • Transmitting single or multiple bytes1:52
  • Creating UART library and it’s functions3:34
  • Additional features6:10
  • UART library usage examples4:01

    ZIP archive contains library itself (uart.c,uart.h) and two examples tested on stm32f103. Note that only example.ioc and main.c files are provided for each example. You can generate project using provided IOC file and then copy and paste example code to newly generated main.c file.

  • Introduction to next modules0:29

Requirements

  • Experience needed: STM32 developer with at least 6 months of experience.
  • You should already know how to use GPIOs and interrupt-driven HAL UART library.

Description

Through this module, you’ll learn how to use STM32’s UART the right way. Everything you’ve seen before is garbage! Just trash it… We will create a serial library which is fast, reliable and can be easily reused in different projects. Multi-port, powered by HAL and compatible with any STM32 microcontroller series.

There are many STM32 UART myths created by incompetent people. E.g., that DMA can’t be used with variable-size data packets and other nonsense. Avoiding DMA peripheral is one of the worst things you can do. It is much simpler to make really good UART code when DMA is used.

Many will say that their UART code is reliable, good, etc. Do you believe it? We will perform two simple tests to ensure that our serial library is reliable: 

  • Loopback test to ensure that each byte is sent and received correctly.

  • Hot-plug test to ensure that communication can be resumed after cable is re-connected.

Our serial library must be portable across multiple STM32 series. Generally, we should consider portability across microcontrollers from different manufactures.  E.g., porting code to Microchip’s PIC32 would be complicated if our library heavily relies on STM32’s “idle” interrupt. Thus, we know what functions to avoid if we want our library to be more portable.

Who this course is for:

  • For professional electronic engineers and firmware developers
  • For anyone who tired of searching how to solve UART problems in their projects