cancel
Showing results for 
Search instead for 
Did you mean: 

STM32F3 Motor Timer Idle Setting / MOE Bit HAL Problems

hemogloben
Associate II
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?

1 ACCEPTED SOLUTION

Accepted Solutions
Amel NASRI
ST Employee
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 Accept as Solution on the reply which solved your issue or answered your question.

View solution in original post

3 REPLIES 3
Amel NASRI
ST Employee
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 Accept as Solution on the reply which solved your issue or answered your question.

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?

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 Accept as Solution on the reply which solved your issue or answered your question.