2021-11-25 05:15 AM
I am trying to implement hall sensor based 6 step control.I am using Timer 1-Channel 1: CH1N and CH1
Channel 2: CH2N and CH2
Channel 2: CH3N and CH3
Now in order to trigger correct mosfets out of 6,i want to enable and disable each pwm indivudual over the run time.
I tried using:
TIM1->CCER|=~TIM_CCER_CC2NE; (example for CH2N)
But once the channel is disabled ,it does not get enable for next cycle even if i enable it by: TIM1->CCER|=TIM_CCER_CC2NE;
I don't know what should be done to control each pwm for 6 step
2021-11-25 06:30 AM
Which STM32?
The CCxE and CCxNE do control individual channels. Note that these bits may be preloaded if CCPC is set.
> TIM1->CCER|=~TIM_CCER_CC2NE; (example for CH2N)
This does not clear the CC2NE bit. This does:
TIM1->CCER &= ~TIM_CCER_CC2NE;
2021-11-25 07:16 AM
Hi,I am using stm32g431cb.I tried using :
TIM1->CCER &= ~TIM_CCER_CC2NE;
But at the next instance when i try to clear the it by :
TIM1->CCER &= TIM_CCER_CC2NE;
it does not work.
What would you suggest to disable and enable each output on channel?Can you give any example?
Thank you for the response
2021-11-25 07:29 AM
> But at the next instance when i try to clear the it by :
> TIM1->CCER &= TIM_CCER_CC2NE;
What are you trying to do with this line? What does "clear the it" mean?
To set the bit and enable the CH2N output (assuming the channel is configured correctly), you would do:
TIM1->CCER |= TIM_CCER_CC2NE;
2021-11-25 07:46 AM
I am trying to control 6 pwm output.
example:
Case 1:
U-phase positive and W-Phase negative
TIM1->CCR1 = 30000; CH1-Enable
TIM1->CCER &= TIM_CCER_CC1NE; CH1N-Disable
TIM1->CCR2 = 0; CH2- Disable
TIM1->CCER &= TIM_CCER_CC2NE; CH2N-Disable
TIM1->CCR3 =0; CH3-disable
TIM1->CCER |= TIM_CCER_CC1NE; CH3N-Enable
Similarly for each case 1 to 6 , i have to chance my pwm output for 6 step i have to control my pwm output.
I am new to STM32.So when i disable a channel in 1st case and enable it in case 2.It does not work.
what should i do?
2021-11-25 08:01 AM
> TIM1->CCER &= TIM_CCER_CC1NE; CH1N-Disable
You are still not clearing the bits correctly. You are missing a "~". See my previous post.
> TIM1->CCER |= TIM_CCER_CC1NE; CH3N-Enable
Why would this enable channel 3N?
I think spending a bit of time proofreading your code would help. I assume these are all typos.
If you're lacking understanding of how to set/clear individual bits, there is a wealth of information available online. These are not STM32-specific operations.
https://stackoverflow.com/questions/47981/how-do-you-set-clear-and-toggle-a-single-bit