2022-07-15 03:29 AM
I have to generate a DMA request using GPIO input pin to change the polarity bit of my TIMER which I'm using as PWM(initial polarity is set to HIGH) to LOW which will change by setting the polarity bit to 1. Whenever the GPIO input pin get a rising edge, I have to trigger the DMA.
Here is the snippet code of what I'm doing.
Here i have configured DMA with request pin(GPIO_EXTI5) (giving a rising edge to this pin using a comparator, and I've checked that this pin is getting a rising edge).
here is the config of GPIO input pin-
and here is the code-
uint32_t DMA_CR_Value = TIM1->CCER | 0x2; // OR with the Timer CCER register so that CC1P bit changes to 1(HIGH to LOW)
HAL_TIM_PWM_Start(&htim1, TIM_CHANNEL_1); // I have to change the polarity of this timer
HAL_DMAEx_EnableMuxRequestGenerator(&hdma_dma_generator1); //Enabling it so that request(trigger by gpio input pin) that we have made would enable
HAL_DMA_Start(&hdma_dma_generator1, (uint32_t)DMA_CR_Value,TIM1->CCER, sizeof(DMA_CR_Value)); // Src- memory to Dst - peripheral
The polarity bit doesn't seems to be changing.
2022-07-16 02:42 AM
See the errata, section 2.2.4
You may still trigger DMA via a timer by using the input pin as timer capture input.