Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Simple, efficient. fast, low resource DMA TX #2844

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

kisslorand
Copy link
Contributor

@kisslorand kisslorand commented Sep 24, 2023

Requirements

BTT or MKS TFT

Description

This PR implements DMA transmit for serial ports as opposite to the current direct (CPU-managed) mode.

Direct Memory Access (DMA) for USART transfer is often considered better than direct (CPU-managed) USART transfers for several reasons. Those applicable to this TFT firmware are:

Offloading CPU: DMA allows the UART communication to occur with minimal CPU intervention. In a direct transfer, the CPU is typically responsible for managing data transfer, which can be resource-intensive and slow down other tasks the CPU needs to perform. With DMA, the CPU sets up the transfer and then lets the DMA controller handle the data movement, freeing up the CPU for other tasks.

Improved Efficiency: DMA controllers are specifically designed to handle data transfers efficiently, with minimal overhead. This can result in faster and more efficient data transfers, especially for larger chunks of data.

Reduced Latency: With direct transfers, the CPU may introduce additional latency in servicing USART requests, leading to delays in data transfer. DMA transfers can significantly reduce this latency, as they can handle data transfers without interrupting the CPU for each byte or character.

Consistency: DMA transfers provide a level of consistency and predictability in data transfer rates, which is beneficial in real-time or time-critical applications. CPU-managed transfers can vary in speed depending on the CPU's current workload.

Multi-Channel Capability: DMA controllers support multiple channels, allowing for concurrent data transfers between different peripherals or memory locations. This is particularly useful in complex embedded systems with multiple communication peripherals (read and write from/to several serial ports at the same time such as of WiFi module, printer, etc.)

Benefits

Based on real tests it frees up more than 20% of the CPU load during print.

Notes

  1. This PR was tested rigorously for a one week period for all the involved MCUs of this FW (even more, it was also tested on GD32F305VCT6 MCU too). However unforeseen bugs might be present so take it as it is, eventually report any bugs you might encounter related to the DMA serial transmission (here or on my repository).
  2. Anyone can feel free to "get inspired" in their own implementation.
  3. @rondlh gets the credit for kicking this in motion
  4. This PR is made mostly for reference for the changelog in my repository where people can have the precompiled FW for their printers with all improvements that the FW of this repository lacks. It's also a testimony that I didn't use other's implementation in my repository.

@kisslorand kisslorand force-pushed the DMA-TX branch 3 times, most recently from c3e2dcd to 4c55adf Compare September 24, 2023 20:37
Copy link

stale bot commented Dec 15, 2023

This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contributions.

Copy link

This PR has been automatically marked as stale because it has had no activity for the last 60 days. It will be closed in 7 days if no further activity occurs. Thank you for your contribution.

@github-actions github-actions bot added the Stale label Apr 20, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant