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

Fix incorrect mapping of DMA channel to DMAMUX channel #80

Merged
merged 2 commits into from
Feb 16, 2024

Conversation

usbalbin
Copy link
Contributor

@usbalbin usbalbin commented Sep 7, 2023

When trying to use the DMA2 peripheral on an STM32G474 I noticed that my buffer did not seem to get written to by the DMA. After some investigation I think I found the issue. From what I can this dma driver does not use the correct mapping from DMA channel to DMAMUX channel for DMA2.

According to RM0440 under "DMAMUX mapping":

For category 3 and category 4 devices:

  • DMAMUX channels 0 to 7 are connected to DMA1 channels 1 to 8
  • DMAMUX channels 8 to 15 are connected to DMA2 channels 1 to 8

For category 2 devices:

  • DMAMUX channels 0 to 5 are connected to DMA1 channels 1 to 6
  • DMAMUX channels 6 to 11 are connected to DMA2 channels 1 to 6

The fix in this PR is quite an ugly hack but it does try to keep the API as unchanged as possible. It only fixes the problem on cat 3 and 4 devices for now(all but G431 and G441).

I get the feeling that the driver as written today works on the (wrong) assumption that every DMA has its own DMAMUX, hence the fn mux_ptr() in Instance. However when implementing the Instance for DMA1 and DMA2 they both use the same one and only DMAMUX.

Therefore i suppose it would make sense to completely remove the fn mux_ptr() from the trait and find some better way than to use my const IS_DMA1: bool.

I am open to suggestions :)

usbalbin and others added 2 commits February 15, 2024 18:06
This is quite an ugly hack but it does try to keep the API as unchanged as possible.
This fix only fixes the problem on cat 3 and 4 devices for now.

According to RM0440 under "DMAMUX mapping":

For category 3 and category 4 devices:
* DMAMUX channels 0 to 7 are connected to DMA1 channels 1 to 8
* DMAMUX channels 8 to 15 are connected to DMA2 channels 1 to 8

For category 2 devices:
* DMAMUX channels 0 to 5 are connected to DMA1 channels 1 to 6
* DMAMUX channels 6 to 11 are connected to DMA2 channels 1 to 6
@usbalbin
Copy link
Contributor Author

@no111u3 would you mind having a look at this? :)

@no111u3 no111u3 merged commit 1d03c22 into stm32-rs:main Feb 16, 2024
23 checks passed
@usbalbin
Copy link
Contributor Author

Thank you! :)

@usbalbin usbalbin deleted the fix_dma branch February 16, 2024 11:59
amcelroy pushed a commit to BridgeSource/stm32g4xx-hal that referenced this pull request Feb 26, 2024
* Fix incorrect mapping of DMA channel to DMAMUX channel

This is quite an ugly hack but it does try to keep the API as unchanged as possible.
This fix only fixes the problem on cat 3 and 4 devices for now.

According to RM0440 under "DMAMUX mapping":

For category 3 and category 4 devices:
* DMAMUX channels 0 to 7 are connected to DMA1 channels 1 to 8
* DMAMUX channels 8 to 15 are connected to DMA2 channels 1 to 8

For category 2 devices:
* DMAMUX channels 0 to 5 are connected to DMA1 channels 1 to 6
* DMAMUX channels 6 to 11 are connected to DMA2 channels 1 to 6

* Fix compilation errors on cat 2 devices
techmccat pushed a commit to techmccat/stm32g4xx-hal that referenced this pull request Jul 30, 2024
* Fix incorrect mapping of DMA channel to DMAMUX channel

This is quite an ugly hack but it does try to keep the API as unchanged as possible.
This fix only fixes the problem on cat 3 and 4 devices for now.

According to RM0440 under "DMAMUX mapping":

For category 3 and category 4 devices:
* DMAMUX channels 0 to 7 are connected to DMA1 channels 1 to 8
* DMAMUX channels 8 to 15 are connected to DMA2 channels 1 to 8

For category 2 devices:
* DMAMUX channels 0 to 5 are connected to DMA1 channels 1 to 6
* DMAMUX channels 6 to 11 are connected to DMA2 channels 1 to 6

* Fix compilation errors on cat 2 devices
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants