cancel
Showing results for 
Search instead for 
Did you mean: 

Using a OC timer as a DMA request.

MCiuf.1
Associate

I am trying to implement a DMA transfer as outlined in AN4666. I am using STM32CubeIDE and an STM32F4 Discovery. This will eventually let me pull data from the input register of a GPIO port (and read a parallel data stream), but for starters, I'm just trying to get it to move data from a dummy array to a buffer.

At the moment, I have Timer 2, Channel 1 configured as an output compare, and DMA1 Stream 5, Channel 3 enabled as peripheral to memory. All the initialization is done by STM32CubeIDE with the HAL driver.

Using the application note as an example, I enable my timer like this:

 uint8_t tmpbuf[10] = {9,9,9,9,9,9,9,9,9,9};
 HAL_DMA_Start(&hdma_tim2_ch1, (uint32_t)&tmpbuf, (uint32_t)&DMABuf, 10);
 __HAL_TIM_ENABLE_DMA(&htim2, TIM_DMA_CC1);
 TIM_CCxChannelCmd(htim2.Instance, TIM_CHANNEL_1, TIM_CCx_ENABLE);
 __HAL_TIM_ENABLE(&htim2);

When I run the code, I can see the timer start (square wave on the output pin), but when I check DMABuf, it still has its initial values.

I've used HAL_TIM_IC_Start_DMA() to do a memory-to-peripheral timer DMA for producing a custom varying PWM waveform, but I've never gone the other way.

I've been poking around at this for a few days now, and I'm not even certain if what I'm trying is possible. Am I missing something?

Thanks in advance.

2 REPLIES 2

You did not tell us which mcu are you using, but if it is 'F2/'F4/'F7, then you probably use DMA1 (as TIM2 tends to be on APB2) and that can't perform memory-to-memory transfers, as its peripheral port is not connected to the bus matrix but is connected directly to APB1, see the busmatrix figure (usually the very first figure in the RM).

JW

MCiuf.1
Associate

Hi JW,

You are right. My issue that I was using DMA1. I'm using the STM32F407, and diagram 33 on the datasheet illustrates that the memory bus does not connect to DMA1's peripheral port.

Thank you!