AnsweredAssumed Answered

STM32F3 Motor Timer Idle Setting / MOE Bit HAL Problems

Question asked by artes.benjamin on Mar 9, 2017
Latest reply on Mar 10, 2017 by Amel N

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, Table 122. of the Reference Manual 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?

Outcomes