How to setup DMA from timer to memory
I'm very new to the STM32 and am trying to set up TIM2 to trigger a dma input capture to memory. I have been pouring over examples and the STM32F302R8 ref manual but am not there yet.
What is working is I am inputting 30Hz ref signal on both PA5 and PB10 (TIM2_Ch1 & TIM2_Ch3). These are being detected and I see the CCR1 and CCR3 registers reflecting the capture count.
What is not working is I don't seem to be generating (or servicing) a DMA request.
In my code I am using HAL_DMA_Start and __HAL_TIM_ENABLE_DMA for both DMA channels 1 & 3 on the TIM2. The respective memory buffers are buffer1 and buffer2 in SRAM. I initialize these to 0xdead at reset and see them get updated once after the DMA is enabled and the TIM2 capture/compare is enabled, but after that the buffer never gets updated again.
Also in the TIM2 SR register the CC10F and CC13F overflow flags are set, and my two DMA IRQ routines never get triggered.
Am I missing a critical enable somewhere?
I've seen in some discussion/examples the use of a Call_Back function. Am I missing a critical piece of code here>
/* Initialize all configured peripherals */
MX_GPIO_Init();
MX_DMA_Init();
MX_ADC1_Init();
MX_DAC_Init();
MX_TIM1_Init();
MX_TIM2_Init();
MX_USART2_UART_Init();
MX_MotorControl_Init();
/* Initialize interrupts */
MX_NVIC_Init();
/* USER CODE BEGIN 2 */
/* USER CODE END 2 */
/* Infinite loop */
/* USER CODE BEGIN WHILE */
NVIC->STIR = EXTI15_10_IRQn; /* what is this for? 5/6/20 */
/* HAL_StatusTypeDef HAL_DMA_Start(DMA_HandleTypeDef *hdma, uint32_t SrcAddress, uint32_t DstAddress, uint32_t DataLength) */
HAL_DMA_Start(&hdma_tim2_ch1, (uint32_t) &TIM2->CCR1, (uint32_t) buffer1, 0x01);
HAL_DMA_Start(&hdma_tim2_ch3, (uint32_t) &TIM2->CCR3, (uint32_t) buffer2, 0x01);
/* enable DMA */
__HAL_TIM_ENABLE_DMA(&htim2, TIM_DMA_CC1);
__HAL_TIM_ENABLE_DMA(&htim2, TIM_DMA_CC3);
/* Start TIM2 then enable capture */
TIM2->CR1 |= TIM_CR1_CEN_Msk; //start the timer
/* *** TIM2 captrure/compare enable register: CCER */
/* [15:12] - Don't care */
/* [11] CC3NP select polarity for capture operation */
/* [10] - reserved */
/* [9] CC3P */
/* [8] CC3E enable */
value |= 0x0100;
/* [7:4] - don't care */
/* [3] CC1NP select polarity for capture operation */
/* [2] - reserved */
/* [1] Set the CC1P bit to zero for active high. */
/* [0] CC1E enable */
value |= 0x0001;
/* Set the TIM2_CCER register: */
TIM2->CCER = value;
while (1)
{Thanks for any and all help,
