Nucleo-g431kb TIM2 Output Compare DMA - When does the dma shift actually trigger?
Hi!
A question related to the 32 bit TIM2 (or timers in general).
I am generating a square wave output using TIM2 Output Compare function with toggle mode.
I have also configured the DMA to help switch the CCRx output compare value in order to go from low to high, and high to low again within a each timer period. At least that is want I want to achieve.
However, the DMA seems to be triggered at when each timer period is finished and not when each compare has happened. Should it not do this?
According to the STM32G4 reference manual, it look like the DMA request should happen after a compare as I expect but not how it is happening?
My timer CUBEMX configuration is as following. The system clock is set maximum 170MHz. Prescale set 0, period is set 170000000-1, so I expect the square puls to be generate 1 time per second. Instead it is generate everyother second.

This is my code initialization of the timer with the DMA buffer:
#define MOTOR_DMA_OC_HIGH 0
#define MOTOR_DMA_OC_LOW 10
static uint32_t m1_tim2_dma_buffer[2] = {MOTOR_DMA_OC_HIGH, MOTOR_DMA_OC_LOW};
void motor_m1_enable(void)
{
HAL_TIM_OC_Start_DMA(&htim2, TIM_CHANNEL_1, m1_tim2_dma_buffer, 2);
}Any inputs from you guys is much appreciated :smiling_face_with_smiling_eyes: