2017-03-09 08:00 AM
I'm currently working on a Motor Controller using the STM32F3. I need the ability to start and stop the motors and, in particular, the ability to switch from moving to stopped and free-wheeling. It would seem that the OCIdleState and OCNIdleState in TIM_OC_InitTypeDef are what I'd want to use to set these states (obviously with OSSI bit set) whenever I'm Idle, but I was having trouble getting it to work.
Long story short, I found that __HAL_TIM_MOE_DISABLE is defined so that it will only clear the MOE bit if both CCxE and CCxNE are 0'd.
#define __HAL_TIM_MOE_DISABLE(__HANDLE__) \
do { \
if (((__HANDLE__)->Instance->CCER & TIM_CCER_CCxE_MASK) == 0) \
{ \
if(((__HANDLE__)->Instance->CCER & TIM_CCER_CCxNE_MASK) == 0) \
{ \
(__HANDLE__)->Instance->BDTR &= ~(TIM_BDTR_MOE); \
} \
} \
} while(0)�?�?�?�?�?�?�?�?�?�?�?�?�?�?�?�?�?�?�?�?
Unless I'm missing something,
shows why this defeats the purpose of the MOE bit and Idle Settings... (With CCxE and CCxNE set to 0 the states of the pins are controlled by GPIO controller instead of timer).Is this a bug? Are there other HAL Functions that I should be using instead?
EDIT: Semi-relatedly, is there a way, in hw, to have the BRK input be able to disable the MOE bit but not re-enable it?
Solved! Go to Solution.
2017-03-09 09:15 AM
Hi
Artes.Benjamin
,In the version 1.7.0 of the
package, a new macro called '__HAL_TIM_MOE_DISABLE_UNCONDITIONALLY' is added to answer requests like yours.If you need more details about timers programming and specially the break feature, I recommend you the following resources:
-Amel
To give better visibility on the answered topics, please click on Accept as Solution on the reply which solved your issue or answered your question.
2017-03-09 09:15 AM
Hi
Artes.Benjamin
,In the version 1.7.0 of the
package, a new macro called '__HAL_TIM_MOE_DISABLE_UNCONDITIONALLY' is added to answer requests like yours.If you need more details about timers programming and specially the break feature, I recommend you the following resources:
-Amel
To give better visibility on the answered topics, please click on Accept as Solution on the reply which solved your issue or answered your question.
2017-03-09 11:39 AM
Thanks for the reply. I see 1.7.0 on the STM32CubeF3 page, but don't see it in STM32CubeMX. Which is preferred?
2017-03-10 02:38 AM
The version 1.7.0 of STM32CubeF3 is supported in the last CubeMX version (4.20).
So you have to install this version first.
-Amel
To give better visibility on the answered topics, please click on Accept as Solution on the reply which solved your issue or answered your question.