Skip to main content
hemogloben
Associate II
March 9, 2017
Solved

STM32F3 Motor Timer Idle Setting / MOE Bit HAL Problems

  • March 9, 2017
  • 3 replies
  • 1330 views
Posted on March 09, 2017 at 17:00

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,

http://www.st.com/content/ccc/resource/technical/document/reference_manual/4a/19/6e/18/9d/92/43/32/DM000435pdf/files/DM000435pdf/jcr:content/translations/en.DM000435pdf#page=585

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?

    This topic has been closed for replies.
    Best answer by Amel NASRI
    Posted on March 09, 2017 at 18:15

    Hi

    Artes.Benjamin

    ‌,

    In the version 1.7.0 of the

    http://www.st.com/content/st_com/en/products/embedded-software/mcus-embedded-software/stm32-embedded-software/stm32cube-embedded-software/stm32cubef3.html

    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

    3 replies

    Amel NASRI
    Amel NASRIBest answer
    ST Technical Moderator
    March 9, 2017
    Posted on March 09, 2017 at 18:15

    Hi

    Artes.Benjamin

    ‌,

    In the version 1.7.0 of the

    http://www.st.com/content/st_com/en/products/embedded-software/mcus-embedded-software/stm32-embedded-software/stm32cube-embedded-software/stm32cubef3.html

    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 "Best Answer" on the reply which solved your issue or answered your question.
    hemogloben
    Associate II
    March 9, 2017
    Posted on March 09, 2017 at 19:39

    Thanks for the reply.  I see 1.7.0 on the STM32CubeF3 page, but don't see it in STM32CubeMX.  Which is preferred?

    Amel NASRI
    ST Technical Moderator
    March 10, 2017
    Posted on March 10, 2017 at 10:38

    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 "Best Answer" on the reply which solved your issue or answered your question.