Thank you for your tutorial. I am new to STM controllers and have been following your tutorials to generate PWM signals using STM32. I'm using an STM32F407 board to generate two PWM signals, and from what I've gathered through online research, I need to use two timers, one in master and another in slave configuration. For the master Timer (Timer 1), I've set up two PWM channels. Channel 1 of Timer 1 is for PWM generation, and Channel 2 of Timer 1 is for triggering Timer 2, which is set to 'output compare no output' mode. I followed your tutorial to configure these channels. What i actually want is to change the phase shift between two these two PWM signals in run time by modifying the CCR registers in the main. The pulse value set in TIM1 CH2 is supposed to change the phase of the PWM generated by Timer 2. However, I'm unable to change the phase at runtime. I've tried changing the value of the CCR2 register in the main code, but it doesn't affect the phase despite updating CCR2. The phase of TIM2's PWM1 is delayed if I set the pulse of TIM1's CH2 in the Pinout and Configuration section of STM32CubeIDE. However, the phase does not change if I modify "htim1.Instance->CCR2" in the main function. This is the problem I am facing. I want to update "htim1.Instance->CCR2" during runtime. Could you please point out my mistake and provide the correct syntax? And if possible, could you explain it in simpler terms, as I'm relatively new to this?
Thank you so much! Little remark. It needs to pay attention to the order of initialization of the master-slave timers in the code. For example, when timer 3 is the master and timer 1 is the slave, when generating the code CubeMX initializes timer 1 first by default. In this case, timer 1 is may starte by itself, asynchronously with the master (timer 3). That is, after the generation of the code, the sequence of initialization of synchronous timers should be adjusted.
I am not sure but I think there is no dedicated feature for it. You can manually do it by using 2 input pins with external interrupt on rising edge. Then start the timer once you get the first trigger and stop the timer on second trigger.
@@ControllersTechhi sir i have question, i used acin 220v for ipm igbt module ( after rectifier i get 310v dc) the ipm can handle till 600v, but my motor only acept 200v. Now how ti reduce duty cycle for HIN and lin input sir?? If i used 50%duty cycle i will get 155v out from ipm right sir??? I used stm32 g431 and st mc worckbench motor control sir
thank you for this work is it possible to vary the phase shift between the two timer in real time by a potentiometer for example. keeping the same frequency.
what if i want to read these three signals, these signals are similar to hall sensor data(120 phase shifted). how will i able to read these signals like 011 , 101, 110 etc
Hello, thank you for your valuable lessons! Is a possible way to implement phase shift between complementary pairs of different channels at the same timer?
As I can see the application of this video is generating phase shifted signals between different timers using master/slave configuration (timer synchronization). I am trying to achieve phase shifted signals at a single timer but different channels. I can see that TIM1 OC2 is used to trigger the TIM2. Mby if I choose Output Compare CH2 (instead of output compare no output) and Toggle on match mode (instead of Active level), will it make it possible?
I don't thik it works like that. The second timer needs to be in slave mode for the synchronization to work. Individual channels can't be configured i. Slave mode. You can try manually though. Start the different channels after some delay. It won't be precise, but if you adjust things properly you might be able to achieve it.
Thank you so much for yor video, i have a question, i did it for 2 Phase, it works great, but after i stop my Timer Master and Slave in order to have Delay, i mean with HAL_ TIM_PWM_STOP, doesn't work my timer slave any more, can you help me about that? Here is my code, and my Tim3 works only one time and not permanently HAL_TIM_PWM_Start(&htim2, TIM_CHANNEL_3) HAL_TIM_OC_Start(&htim2, TIM_CHANNEL_4) HAL_TIM_PWM_Start(&htim3, TIM_CHANNEL_2) HAL_Delay(200) HAL_TIM_PWM_Stop(&htim2, TIM_CHANNEL_3) HAL_TIM_OC_Stop(&htim2, TIM_CHANNEL_4) HAL_TIM_PWM_Stop(&htim3, TIM_CHANNEL_2) HAL_Delay(200)
Hello! How can I change in main.c the value of OC2REF in TIM1. I tried to put in while TIM1 -> CCR2 = 3000; but this not change anything. Can you help me?
Anybody can help me? I tryed everything but only way to change is in the beggining on the boxes, I want to phase shift in a while the value that i want to put and change again and so on
@@alexandrev.3332 Were you able to do so? I am also having that problem and need to phase sift from one value to another at a certain time while code is running