2024-10-29 01:55 AM
Hi im using stm32g474vet6 mcu , in that im using internal comparator for PWM SHUTDOWN for protection purpose.
im using comp4. comp4 input pin is directly shorted to ADC pin and reference voltage is giving using DAC.
in the below attached image
yellow color : sudden change in adc signal which is going to comparator input.
blue color : comparator output is taken out using gpio of mcu
green color : pwm signal from mcu.
in that image u can see that the sudden change in adc crosses the threshold value of comparator, and comparator output is become high , during that time pwm signal is not stoping exactly , it is shutdown at after the completion of that ON cycle, where as in pwm OFF cycle this is not happening pwm is shutting down fastly.'
to shutdown that pwm fastly what to do ? these things are done in stm32cubeide ioc file configuration setting of timer1, in that i have enabled only comparator output and not the TIM1_BKIN.
2024-10-29 02:13 AM
> i have enabled only comparator output and not the TIM1_BKIN
So, what is the mechanism of the timer "shutdown", then?
Read out and check/post content of TIM1 and perhaps also COMP registers.
JW
2024-10-29 02:18 AM
TIM1_BKIN- > in this we can give external signal to tim1_bkin for pwm shutdown , there will be some setting in stm32 ioc file activate break interrupt- i havent enabled that one, i have enabled only comparator signlas
2024-10-29 02:47 AM
For exact behaviour of BREAK functionality, read the Using the break function subchapter of TIM1 chapter in RM. There are several options what can happen, depending on setting of several bits:
This all only if you indeed have selected the output of comparator to trigger a BREAK (i.e. the respective TIMx_AF1.BKCMPxE set and TIMx_BDTR.BKE set), rather than using the comparator as OCREF_CLR source (as selected by TIMx_AF2.OCRSEL and enabled by TIMx_CCMRx.OCxCE).
JW
2024-10-29 03:21 AM
thank you for that note,
but im configuring in stm32 ioc file in that what settings i have to enable to shutdown the pwm fastly when comparator reaches its threshold,
any way im using
__HAL_TIM_CLEAR_FLAG(&htim1,TIM_FLAG_BREAK);
__HAL_TIM_MOE_ENABLE(&htim1);
to enable the pwm signal again after clearing the comparator fault.
please find the below images for settings done in ioc file
comparator works fine and pwm shutting down , i want to happen it fastly
could u please suggest any solution