Change timers output compare mode
Hello,
I have a problem, I would like to change a timer output compare mode on my STM32G484xE microcontroller. I would like to switch between toggle and PWM mode 1. I do the whole thing with a small function for writing registers:
void ProgRegister(uint32_t *RegAddr, uint32_t Bits, uint32_t BitMask){
*RegAddr = (*RegAddr & ~BitMask) | Bits;
}This is how I switch to the different output compare modes:
//switch to toggle mode
ProgRegister((uint32_t*) &TIM1->CCMR1, TIM_CCMR1_OC1M_0 | TIM_CCMR1_OC1M_1, TIM_CCMR1_OC1M); // 0011 Toggle
//switch to pwm mode 1
ProgRegister((uint32_t*) &TIM1->CCMR1, TIM_CCMR1_OC1M_2 | TIM_CCMR1_OC1M_1, TIM_CCMR1_OC1M); // 0110 PWM Mode 1The timer is initialized in toggle mode, and if I then want to set it to PMW1 mode, it remains in toggle mode. The LOCK bits are also not set, so I should be able to write to the registers.
Do you have any idea what my problem could be, so that the mode does not switch?
