Question
Clearing the OCxREF signal on an external event
Posted on February 14, 2013 at 14:30
Hello.
As described on STM32F100 manual:The OCxREF signal for a given channel can be driven Low by applying a High level to the ETRF input (OCxCE enable bit of the corresponding TIMx_CCMRx register set to ‘1’). The OCxREF signal remains Low until the next update event, UEV, occurs.
For example, the OCxREF signal) can be connected to the output of a comparator to be used for current handling.
I am trying to do this, and I am using 3 PWM for BLDC motor control (wich works very well for now but lacks current control). I am using OC1, OC2 and OC3 for PWM generation.When ETR pin is active (output of a LM258 comparator when over current), ONLY the OC3Ref signal is clear and so I only get PWM channel 3 off on over current while channel 1 and 2 should also be off.Where is the code configuration for ETR:
GPIO_InitStructure
.
GPIO_Pin
=
GPIO_Pin_12
;
GPIO_InitStructure
.
GPIO_Mode
=
GPIO_Mode_IN_FLOATING
;
GPIO_InitStructure
.
GPIO_Speed
=
GPIO_Speed_50MHz
;
GPIO_Init
(
GPIOA
,
&
GPIO_InitStructure
);
/* configure ETR for current control */
TIM_ETRConfig
(
TIM1
,
TIM_ExtTRGPSC_OFF
,
TIM_ExtTRGPolarity_NonInverted
,
0
);
TIM_ClearOC1Ref
(
TIM1
,
TIM_OCClear_Enable
);
TIM_ClearOC2Ref
(
TIM1
,
TIM_OCClear_Enable
);
TIM_ClearOC3Ref
(
TIM1
,
TIM_OCClear_Enable
);
My code is here:
This is an OpenSource motor BLDC controller, project page: Right now the motor works very well, including the Hall Sensor and Brake (using STM32 hardware for this). The only thing missing is over current control.Thank you in advance.