Skip to content

Use DMA in custom C module without breaking Micropython DMA definitions #16386

Discussion options

You must be logged in to vote

You can configure and use the DMA in a user C module, I've done this recently to work with timer capture units. You do need to choose channels that aren't already in use on the particular chip you're using.

I had to use a mix of the microypthon dma init functions (to ensure the correct handles are configured that the interrupts expect) as well as the HAL functions (to configure settings not exposed by the micropython functions).

Here's some snippets from my C code, hopefully they help

#include "py/runtime.h"
#include "py/mphal.h"

#include "ports/stm32/dma.h"
#include "ports/stm32/pin.h"
#include "ports/stm32/timer.h"

#define SIGGEN_DMA_CHANNEL DMA2_Channel1
#define SIGGEN_DMA_CHANNEL_IRQ

Replies: 1 comment 7 replies

Comment options

andrewleech
Dec 11, 2024
Collaborator Sponsor

You must be logged in to vote
7 replies
@eliclement
Comment options

@andrewleech
Comment options

andrewleech Dec 13, 2024
Collaborator Sponsor

@eliclement
Comment options

@eliclement
Comment options

@andrewleech
Comment options

andrewleech Dec 15, 2024
Collaborator Sponsor

Answer selected by eliclement
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
2 participants