Author Topic: Multi-port DMA uart library for all STM32 series (f1,f4,h7,etc.) and pic32mk.  (Read 2012 times)

0 Members and 1 Guest are viewing this topic.

Offline Georgy.MoshkinTopic starter

  • Regular Contributor
  • *
  • Posts: 139
  • Country: hk
  • R&D Engineer
    • Electronic projects, modules and courses on Arduino and STM32
Download: stm32uart.zip - library with two usage examples (stm32cubeide ioc files with main.c for stm32f103c8t6).
How-to (using stm32cubeide configurator window):
1) Enable 3 uart ports
2) Enable global interrupt for each port
3) Enable TX and RX dma channels
4) Set all RX dma channel modes to circular
5) Generate code
6) Add uart.h, uart.c to path, include uart.h
7) Use COM_Init(handle,buffer,buffer_size,timeout) on each HAL port
8) Use COM_Select(), COM_Read(), COM_Write()

It is stripped down version of my UART library. Functions removed: CRC32, retry algorithm, PIC32 support, hexadecimal strings parsing, mem2mem, etc. I made this version for my tutorial in STM32. This version may have some bugs, but the method was tested on stm32f103,f407,f446,h750,h7b0. I tried to keep it simple, rs485 support not tested in this version. I'll post PIC32MK version later + add comments from tutorial.

3-port usage example (don't forget to enable 3 uarts, their global interrupts and circular mode for RX dma channels):




On STM32H7 you need to put uart buffer in DMA memory. Write functions can be modified to send data from non-DMA memory (copy to temporary buffer that can be accessed by dma).
« Last Edit: September 28, 2023, 02:21:36 pm by Georgy.Moshkin »
 
The following users thanked this post: bingo600

Offline Georgy.MoshkinTopic starter

  • Regular Contributor
  • *
  • Posts: 139
  • Country: hk
  • R&D Engineer
    • Electronic projects, modules and courses on Arduino and STM32
Added video tutorials:

1. Step-by-step 5 port Uart DMA on STM32H750


2. UART Library on stm32f030 and stm32g030


Attached version with little fix for STM32F4. Latest version will be available here.

Offline bingo600

  • Super Contributor
  • ***
  • Posts: 1963
  • Country: dk
Thanx for the effort.

But I'll have to pass on the new uart lib for the F030.
Registering everywhere just to dl. a library is too cubersome , even if it's free (ATM)

Nice PDF guide  :-+

/Bingo

« Last Edit: December 03, 2023, 09:46:25 am by bingo600 »
 

Offline Georgy.MoshkinTopic starter

  • Regular Contributor
  • *
  • Posts: 139
  • Country: hk
  • R&D Engineer
    • Electronic projects, modules and courses on Arduino and STM32
Registering everywhere just to dl. a library is too cubersome , even if it's free (ATM)
Downloading these files does not require registration (if you came using link from my youtube channel)
email-free login link:
https://www.thundertronics.com/?sid=8b063142aba00592bb12c338675b3aa4

downloads
https://www.thundertronics.com/STM32_UART_Library/How%20To%20Use%20STM32%20UART.pdf
https://www.thundertronics.com/STM32_UART_Library/loopback-win32-v1_0.zip
https://www.thundertronics.com/STM32_UART_Library/stm32uart-v1_0.zip (with fixed define for stm32f4: here)
« Last Edit: December 19, 2023, 12:30:20 pm by Georgy.Moshkin »
 


Share me

Digg  Facebook  SlashDot  Delicious  Technorati  Twitter  Google  Yahoo
Smf