cancel
Showing results for 
Search instead for 
Did you mean: 

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

TLi.3
Associate

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.

1 ACCEPTED SOLUTION

Accepted Solutions

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.

View solution in original post

3 REPLIES 3
Laurent Ca...
Lead II

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...

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...
Lead II

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

Best regards