Skip to main content
TLi.3
Associate
December 18, 2020
Solved

Driver motor program error when I use hall sensor and encoder at the same time

  • December 18, 2020
  • 2 replies
  • 2448 views

My platform is:

STM32F407IG​ ,MotorControl Workbench 5.4.4,IAR EMARM V8,STM32 FW V1.24.1

When I use both the Hall sensor and the encoder, the encoder serves as the Main sensor and the Hall sensor as the Auxiliary sensor.The code it generates has a warning:

Warning[Pa181]: incompatible redefinition of macro "SPD_TIM_M1_IRQHandler" (declared at line 268)

It prompted me to define both the Hall sensor and the encoder timer as SPD_TIM_M1/2_IRQHandler.0693W000006GHpbQAG.pngAnd the notes are all hints as AUXILIARY ** TIMER MOTOR.

When I was debugging, the program got stuck after “HAL_NVIC_EnableIRQ(TIM5_IRQn);�?

It loops around here:

​​0693W000006GHqKQAW.pngIs my engineering configuration not right or cannot be used in this way,If you encounter this problem, please communicate with me.

Thank you so much.

This topic has been closed for replies.
Best answer by TLi.3

Oh,Hi�?happy new year!

​I've solved it.I guess it was a bug generated when generating code.

I added the TIM interrupt used by the encoder.And renamed the macro definition of the encoder capture.And it works.

Change the name of the duplicate macro definition:

0693W000006HM2qQAG.png​Write interrupt functions 1:

0693W000006HM30QAG.pngChannel two is the same as channel one.

Best regards

Tengjie Li.

2 replies

Laurent Ca...
Senior III
December 31, 2020

Dear @TLi.3​ 

Sorry for the late answer.

Do you have still this problem to solve?

And just in case, if not, do not hesitate to share the final solution you found. Thanks by advance.

Best regards

Laurent Ca...

TLi.3
TLi.3AuthorAnswer
Associate
January 4, 2021

Oh,Hi�?happy new year!

​I've solved it.I guess it was a bug generated when generating code.

I added the TIM interrupt used by the encoder.And renamed the macro definition of the encoder capture.And it works.

Change the name of the duplicate macro definition:

0693W000006HM2qQAG.png​Write interrupt functions 1:

0693W000006HM30QAG.pngChannel two is the same as channel one.

Best regards

Tengjie Li.

Laurent Ca...
Senior III
June 28, 2021

The question has been set only to the "STM32 Motor Control" topic (the question is only about the STM32 MC SDK). 

Best regards