Unable to frequently read motor hall sensor in XOR ON / Hall Sensor Mode
I am designing a BLDC motor controller using STM32F103C8T6. I am using "XOR ON / Hall Sensor Mode" for reading the motor's hall sensor. But if the motor is rotated quickly, the hall sensor value does not update. The hall sensor value updates properly if motor is rotated very slowly. I have removed all other parts from the code, The only code in the program is of reading hall sensor pins.
void TIM4_IRQHandler(void)
{
/* USER CODE BEGIN TIM4_IRQn 0 */
hallPosx =
((HAL_GPIO_ReadPin( HW_GPIO_Port, HW_Pin ) << 2)
|(HAL_GPIO_ReadPin( HV_GPIO_Port, HV_Pin ) << 1)
| HAL_GPIO_ReadPin( HU_GPIO_Port, HU_Pin ) );
);
if (0U == LL_TIM_IsActiveFlag_UPDATE(TIM4))
{
/* Nothing to do */
}
else
{
LL_TIM_ClearFlag_UPDATE(TIM4);
}
if (LL_TIM_IsActiveFlag_CC1 (TIM4) != 0U)
{
LL_TIM_ClearFlag_CC1(TIM4);
}
else
{
/* Nothing to do */
}
/* USER CODE END TIM4_IRQn 0 */
/* USER CODE BEGIN TIM4_IRQn 1 */
/* USER CODE END TIM4_IRQn 1 */
}
This is the configuration.

