timer_dma_enable_trg_req(timer->dev);#include <libmaple/dma.h>
#define dma_bufer_size 48
long dma_bufer[dma_bufer_size];
//dmx driver
//d- PA2
//d+ PA3
#define dmx0 0x80004;
#define dmx1 0x40008;
HardwareTimer timer(2);
dma_tube_config tube_config;
void setup() {
//fill dma bufer
int fps=0;
do{
dma_bufer[fps++]=dmx0;
dma_bufer[fps++]=dmx1;
}while(fps<dma_bufer_size);
pinMode(PA2,OUTPUT);
pinMode(PA3,OUTPUT);
//DMA setup
tube_config.tube_src = dma_bufer;
tube_config.tube_src_size = DMA_SIZE_32BITS;
tube_config.tube_dst = &GPIOA->regs->BSRR; // Load pointer to porta clear/set
tube_config.tube_dst_size = DMA_SIZE_32BITS;
tube_config.tube_nr_xfers = dma_bufer_size;
tube_config.tube_flags = DMA_CFG_SRC_INC | DMA_CFG_CIRC; // Source pointer increment,circular mode
tube_config.target_data = 0;
dma_init(DMA1);
tube_config.tube_req_src = DMA_REQ_SRC_TIM2_CH3; // DMA request source.
dma_set_priority(DMA1, DMA_CH1,DMA_PRIORITY_VERY_HIGH);
dma_tube_cfg(DMA1, DMA_CH1, &tube_config); // Attach the tube to channel 1 (timer2 ch3)
dma_enable(DMA1, DMA_CH1);
//TIMER setup
timer.pause();
timer.setPeriod(2000000);//2 seconds
timer.setChannel3Mode(TIMER_OUTPUT_COMPARE);
timer.setCompare(TIMER_CH3, 1);
timer_dma_enable_trg_req(TIMER2);
timer.resume();
}
void loop() {
while(1){
//commented code is what dma is supposed to do.(blink a led connected to PA2-PA3)
/*
GPIOA->regs->BSRR=dmx0;
delay(2000);
GPIOA->regs->BSRR=dmx1;
delay(2000);*/
};
}
https://github.com/rogerclarkmelbourne/ … nfig&type=
https://github.com/rogerclarkmelbourne/ … nfig&type=
Just comments
https://github.com/rogerclarkmelbourne/ … aple/dma.h
However, it is not finding SdFat.h or this file for me.
#include <libmaple/dma.h>tube source = &dma_buffer; // note the “&”
tube dest = &GPIOA->regs->ODR; // only the lowest 16 bits are used, so you could use 16 bit transfer, increasing the number of samples to store in buffer
I am not sure that you selected the correct source for DMA trigger. Shouldn’t be the CC output of TIM2 CH3?
Extract from RM0008:
"In addition, if the URS bit (update request selection) in TIMx_CR1 register is set, setting the
UG bit generates an UEV update event but without setting the UIF flag (thus no interrupt or
DMA request is sent)."


