cancel
Showing results for 
Search instead for 
Did you mean: 

STSW-SPIN3204 firmware questions

Vnguy.1
Associate II

Hello Friends and ST engineer.

I am controlling BLDC motor using STSW-SPIN3204 firmware with Hall Sensor. But some functions I do not understand, please explain more detail for me.

  1. HAL_TIM_OC_DelayElapsedCallback: what is this function for? why we use output compare in input capture with hall sensor.
  2. MC_TIMx_SixStep_CommutationEvent(): @brief: Capture the counter value for which the hall sensors status changed and set the delay at which the HF_TIMx will change according to the new hall status value and hence new step.

I do not understand this function for what? please tell more detail for me

If you have the detail document, please give

Thank you so much.

Best regards.

1 ACCEPTED SOLUTION

Accepted Solutions

Hi @Vnguy.1​ 

The TIM_SelectOCxM function comes from the old standard libraries for STM32. The new HAL doesn't provide this specific function.

In any case the objective here is managing the channels of HF timer in order to set the high-impedance state in one of the phases.

The code achieve this result through the writing of the CCER register and enabling/disabling the channels.

Enrico

View solution in original post

9 REPLIES 9
ORaph.1
Associate II

how much pole pairs are there in your motor..? i am trying to work with single pole pair motor and the firmware i got is with 7 pole pair,i am stuck at changing the firmware to single pole pair....do you have any idea about this..?

Hi @ORaph.1​ 

You can open a new post for this.

Regards

Enrico

Enrico Poli
ST Employee

hi @Vnguy.1​ 

The HAL_TIM_OC_DelayElapsedCallback is called by the triggering of the timeout between Hall sensor commutation (IC capture) and changes of the HF timer configuration (commutation event).

This delay is set using one OC channel of the LF timer.

Basically the HF timer configuration (TIM1) is pre-loaded into the shadow registers and when this timeout is elapsed the new values became active. This allows a perfect synchronization of the 3 phases of the motor.

This is the "commutation event" and it is automatically triggered by the internal master/slave system of the MCU.

The MC_TIMx_SixStep_CommutationEvent sets the delay between the IC capture (Hall commutation) and the commutation event of TIM1 allowing this synchronization.

Summary:

Hall sensor commutation --> LF_TIM IC capture --> MC_TIMx_SixStep_CommutationEvent setting a delay

Delay expires --> LF_TIM OC delayelapsed --> HF_TIM Commutation event

The code inside the HAL_TIM_OC_DelayElapsedCallback checks that the Hall sesnors are commutating as expected and the motor is not locked.

Kind Regards

Enrico

Hi Enrico Poli.

Thank you so much for your information, it is really useful for me.

But after I read the STSW-SPIN3204 firmware, I got some troubles, please explain to me.

  1. As you can see the below picture, in the hall sensor case, there is no initialization for master/slave in commutation event (main.c). Is this code right or not? I think this code is not true.

 0693W000005D2XwQAK.jpg 

2 . May you explain to me why MC_TIMx_SixStep_timebase() function is called 2 times, first is in HAL_TIM_PeriodElapsedCallback(), and second is in HAL_TIM_IC_CaptureCallback()? I think it will be called 1 time in HAL_TIM_IC_CaptureCallback() as enough.

3 . For example, when Input capture happens HAL_TIM_IC_CaptureCallback() is called , assume that hall status = 2, it means as case 2 in MC_SixStep_NEXT_step(), next_step_pos = 1, this function sets up the CCR1 = pulse_value. As the below picture, I think we should set up the CCR2 = pulse_value, is that correct? For my understanding, after the commutation delay, HAL_TIM_OC_DelayElapsedCallback() is then called. At that time, next_step_pos = 2. And then MC_SixStep_TABLE(2) is called, in case 2 in MC_SixStep_TABLE(2) set up CH1, and CH3. It made me so confused. May you explain to me? Thank you so much.

0693W000005D2WtQAK.jpg 

Best Regards

Hi @Vnguy.1​ ,

Following my answer to your points:

  1. Master/slave between the two timers is "hidden" into the "HAL_TIMEx_HallSensor_Init(&LF_TIMx, &sHallSensorConfig)" function
  2. MC_TIMx_SixStep_timebase() is the function that changes the step. Due to the general purpose of the firmware, it is called in the HAL_TIM_IC_CaptureCallback() when using the hall sensors and in the HAL_TIM_PeriodElapsedCallback() when the sensorless mode is selected. The HAL_TIM_PeriodElapsedCallback() is not triggered in the hall sensor mode.
  3. In Hall sensor mode the pulse value is configured during the HAL_TIM_IC_CaptureCallback (). The HAL_TIM_OC_DelayElapsedCallback () operates during startup phase only in case of unexpected timout of the Hall sensor timer. In fact the very first conditioning here checks the Hall_ok status condition.

Kind Regards

Enrico

Hi Enrico Poli

Thank you so much for your reply.

One question I would like to ask you.

In order to set or reset OCxM, some document use the TIM_SelectOCxM command. but in MC_SixStep_NEXT_step() function, there is no TIM_SelectOCxM to control OCxM as the below picture. May you explain for me? 0693W000006EQRyQAO.jpgThank you so much

Best Regards.

Hi @Vnguy.1​ 

The TIM_SelectOCxM function comes from the old standard libraries for STM32. The new HAL doesn't provide this specific function.

In any case the objective here is managing the channels of HF timer in order to set the high-impedance state in one of the phases.

The code achieve this result through the writing of the CCER register and enabling/disabling the channels.

Enrico

Hi @Vnguy.1​ ,

If you think my replies answer your doubts, please mark them ad "Best answer".

This will help other community members to find the support they are looking for.

Thanks!

Enrico

Hi Enrico Poli

I am sorry for reply late

Thank you for your help and your time.

I got many in formation from you.

Best Regards and Keep safe.