Skip to main content
Associate III
May 17, 2023
Question

How to configure Timer input XOR for STM32G030K6T6 Microcontroller ?

  • May 17, 2023
  • 3 replies
  • 1656 views

..

This topic has been closed for replies.

3 replies

waclawek.jan
Super User
May 17, 2023


_legacyfs_online_stmicro_images_0693W00000bkHuLQAU.pngJW

Associate III
May 18, 2023

Thank you for your response.

I tried with the STM32F1 series it worked well. when I did with the STM32G030K6t6 it doesn't work

when there is any change in the input TIM counter(xor timer) reset to zero but it doesn't work in STM32G030K6t6

below I have attached my initialization TIM3 for the XOR operation

void MX_TIM3_Init(void)
{
 
 /* USER CODE BEGIN TIM3_Init 0 */
 
 /* USER CODE END TIM3_Init 0 */
 
 TIM_ClockConfigTypeDef sClockSourceConfig = {0};
 TIM_HallSensor_InitTypeDef sConfig = {0};
 TIM_MasterConfigTypeDef sMasterConfig = {0};
 
 /* USER CODE BEGIN TIM3_Init 1 */
 
 /* USER CODE END TIM3_Init 1 */
 htim3.Instance = TIM3;
 htim3.Init.Prescaler = 65535;
 htim3.Init.CounterMode = TIM_COUNTERMODE_UP;
 htim3.Init.Period = 65535;
 htim3.Init.ClockDivision = TIM_CLOCKDIVISION_DIV1;
 htim3.Init.AutoReloadPreload = TIM_AUTORELOAD_PRELOAD_DISABLE;
 if (HAL_TIM_Base_Init(&htim3) != HAL_OK)
 {
 Error_Handler();
 }
 sClockSourceConfig.ClockSource = TIM_CLOCKSOURCE_INTERNAL;
 if (HAL_TIM_ConfigClockSource(&htim3, &sClockSourceConfig) != HAL_OK)
 {
 Error_Handler();
 }
 sConfig.IC1Polarity = TIM_ICPOLARITY_RISING;
 sConfig.IC1Prescaler = TIM_ICPSC_DIV1;
 sConfig.IC1Filter = 0;
 sConfig.Commutation_Delay = 0;
 if (HAL_TIMEx_HallSensor_Init(&htim3, &sConfig) != HAL_OK)
 {
 Error_Handler();
 }
 sMasterConfig.MasterOutputTrigger = TIM_TRGO_OC2REF;
 sMasterConfig.MasterSlaveMode = TIM_MASTERSLAVEMODE_DISABLE;
 if (HAL_TIMEx_MasterConfigSynchronization(&htim3, &sMasterConfig) != HAL_OK)
 {
 Error_Handler();
 }
 /* USER CODE BEGIN TIM3_Init 2 */
 
 /* USER CODE END TIM3_Init 2 */
 
}

waclawek.jan
Super User
May 18, 2023

Read out and check/compare-to-working/post content of TIM registers.

JW