2015-11-23 07:16 AM
Hi,
I would like to use the DMA with diferent peripherals of a stmHere are the resuming points.
target MCU: STM32L0 purpose : Dma + uart1+uart2+uart3 +spi+i2c For instance i succeded configuring the uart2 with the dma with the following configuration://UART2
hdma_tx.Instance = DMA1_Channel4;
hdma_tx.Init.Request = DMA_REQUEST_4;
__HAL_LINKDMA(UartObject_tS, hdmatx, hdma_tx);
//(...)
HAL_DMA_Init(&hdma_tx);
hdma_rx.Instance = DMA1_Channel5;
hdma_rx.Init.Request = DMA_REQUEST_4;
__HAL_LINKDMA(UartObject_tS, hdmarx, hdma_rx);
//(...)
if i change the configuration to uart1 it would give something like this:
//UART1
hdma_tx.Instance = DMA1_Channel2;
hdma_tx.Init.Request = DMA_REQUEST_3;
__HAL_LINKDMA(UartObject_tS, hdmatx, hdma_tx);
//(...)
HAL_DMA_Init(&hdma_tx);
hdma_rx.Instance = DMA1_Channel3;
hdma_rx.Init.Request = DMA_REQUEST_3;
__HAL_LINKDMA(UartObject_tS, hdmarx, hdma_rx);
//(...)
I tested each one separately and the corresponfding IRQ handler is triggered.
Now if i would like to use the UART1, UART2 and LPUART1 (aka UART3). I would apply the same reasoning.//UART3 aka LPUART1
hdma_tx.Instance = DMA1_Channel7;
hdma_tx.Init.Request = DMA_REQUEST_5;
__HAL_LINKDMA(UartObject_tS, hdmatx, hdma_tx);
//(...)
hdma_rx.Instance = DMA1_Channel6;
hdma_rx.Init.Request = DMA_REQUEST_5;
__HAL_LINKDMA(UartObject_tS, hdmarx, hdma_rx);
//(...)
At this point i think all is ok as each DMA channel has individual peripheral request signals.
But what happens if i need to use the spi2 in the same way knowing that all dma channel request are used?
According the datasheet ( ''only one request shall be enabled at a time'' (p240)) and the dma request mapping (p241) , how can I achieve this ? is it possible ? Shall another strategy be followed? Can other peripheral request signals be mapped in the same dma channel ??
If yes, how are they handdled ?
Thanks in advance. #stm32 #uart #spi #dma2015-11-23 08:38 AM
I'm not using the F0 or HAL,
The DMA resources are finite, consider if it's worth using for I2C and USART RX applications, as these would be the least efficient uses.2015-11-23 09:35 AM
2015-11-23 10:18 AM
I'm not using Cortex-M0 (F0/L0) parts in any of the work I'm doing, I also use the SPL (Standard Peripheral Library) that predates the HAL. I have long standing opinions on the HAL/Cube mess that I'm not going to get into in this thread.
So I gave general direction has to how to use the resources. The STM32 is a general purpose design, so basically you aren't likely to be able to run all peripherals and have them all escape the pins, or have DMA service every peripheral. You have to balance them. DMA is best suited to TX tasks where the length of the transfer is known in advance. For short RX tasks, where there is less, intermittent, or variable length data, DMA will be very difficult to manage efficiently. The HAL layers a pretty thick abstraction on the hardware.You'll need to look a the DMA matrix and pick a function from each column.