Core/Src/main.c
static void MX_TIM3_Init(void)
{

  /* USER CODE BEGIN TIM3_Init 0 */

  /* USER CODE END TIM3_Init 0 */

  TIM_MasterConfigTypeDef sMasterConfig = {0};
  TIM_OC_InitTypeDef sConfigOC = {0};

  /* USER CODE BEGIN TIM3_Init 1 */

  /* USER CODE END TIM3_Init 1 */
  htim3.Instance = TIM3;
  htim3.Init.Prescaler = 600;
  htim3.Init.CounterMode = TIM_COUNTERMODE_UP;
  htim3.Init.Period = 100;
  htim3.Init.ClockDivision = TIM_CLOCKDIVISION_DIV1;
  htim3.Init.AutoReloadPreload = TIM_AUTORELOAD_PRELOAD_DISABLE;
  if (HAL_TIM_PWM_Init(&htim3) != HAL_OK)
  {
    Error_Handler();
  }
  if (HAL_TIM_OnePulse_Init(&htim3, TIM_OPMODE_SINGLE) != HAL_OK)
  {
    Error_Handler();
  }
  sMasterConfig.MasterOutputTrigger = TIM_TRGO_RESET;
  sMasterConfig.MasterSlaveMode = TIM_MASTERSLAVEMODE_DISABLE;
  if (HAL_TIMEx_MasterConfigSynchronization(&htim3, &sMasterConfig) != HAL_OK)
  {
    Error_Handler();
  }
  sConfigOC.OCMode = TIM_OCMODE_PWM1;
  sConfigOC.Pulse = 1;
  sConfigOC.OCPolarity = TIM_OCPOLARITY_LOW;
  sConfigOC.OCFastMode = TIM_OCFAST_DISABLE;
  if (HAL_TIM_PWM_ConfigChannel(&htim3, &sConfigOC, TIM_CHANNEL_2) != HAL_OK)
  {
    Error_Handler();
  }
  /* USER CODE BEGIN TIM3_Init 2 */
    HAL_TIM_Base_Start(&htim3);
    HAL_TIM_PWM_Start(&htim3, TIM_CHANNEL_2);
  /* USER CODE END TIM3_Init 2 */
  HAL_TIM_MspPostInit(&htim3);

}
/**
  * @brief TIM3 Initialization Function
  * @param None
  * @retval None
  */
@brief TIM3 Initialization Function
@param None
@retval None
@brief TIM3 Initialization Function @param None @retval None
static void MX_TIM3_Init(void)
{
  TIM_MasterConfigTypeDef sMasterConfig = {0};
  TIM_OC_InitTypeDef sConfigOC = {0};
  htim3.Instance = TIM3;
  htim3.Init.Prescaler = 600;
  htim3.Init.CounterMode = TIM_COUNTERMODE_UP;
  htim3.Init.Period = 100;
  htim3.Init.ClockDivision = TIM_CLOCKDIVISION_DIV1;
  htim3.Init.AutoReloadPreload = TIM_AUTORELOAD_PRELOAD_DISABLE;
  if (HAL_TIM_PWM_Init(&htim3) != HAL_OK)
  {
    Error_Handler();
  }
  if (HAL_TIM_OnePulse_Init(&htim3, TIM_OPMODE_SINGLE) != HAL_OK)
  {
    Error_Handler();
  }
  sMasterConfig.MasterOutputTrigger = TIM_TRGO_RESET;
  sMasterConfig.MasterSlaveMode = TIM_MASTERSLAVEMODE_DISABLE;
  if (HAL_TIMEx_MasterConfigSynchronization(&htim3, &sMasterConfig) != HAL_OK)
  {
    Error_Handler();
  }
  sConfigOC.OCMode = TIM_OCMODE_PWM1;
  sConfigOC.Pulse = 1;
  sConfigOC.OCPolarity = TIM_OCPOLARITY_LOW;
  sConfigOC.OCFastMode = TIM_OCFAST_DISABLE;
  if (HAL_TIM_PWM_ConfigChannel(&htim3, &sConfigOC, TIM_CHANNEL_2) != HAL_OK)
  {
    Error_Handler();
  }
    HAL_TIM_Base_Start(&htim3);
    HAL_TIM_PWM_Start(&htim3, TIM_CHANNEL_2);
  HAL_TIM_MspPostInit(&htim3);
}
static void MX_TIM3_Init ( void ) { TIM_MasterConfigTypeDef sMasterConfig = { 0 } ; TIM_OC_InitTypeDef sConfigOC = { 0 } ; htim3 . Instance = TIM3 ; htim3 . Init . Prescaler = 600 ; htim3 . Init . CounterMode = TIM_COUNTERMODE_UP ; htim3 . Init . Period = 100 ; htim3 . Init . ClockDivision = TIM_CLOCKDIVISION_DIV1 ; htim3 . Init . AutoReloadPreload = TIM_AUTORELOAD_PRELOAD_DISABLE ; if ( HAL_TIM_PWM_Init ( & htim3 ) != HAL_OK ) { Error_Handler ( ) ; } if ( HAL_TIM_OnePulse_Init ( & htim3 , TIM_OPMODE_SINGLE ) != HAL_OK ) { Error_Handler ( ) ; } sMasterConfig . MasterOutputTrigger = TIM_TRGO_RESET ; sMasterConfig . MasterSlaveMode = TIM_MASTERSLAVEMODE_DISABLE ; if ( HAL_TIMEx_MasterConfigSynchronization ( & htim3 , & sMasterConfig ) != HAL_OK ) { Error_Handler ( ) ; } sConfigOC . OCMode = TIM_OCMODE_PWM1 ; sConfigOC . Pulse = 1 ; sConfigOC . OCPolarity = TIM_OCPOLARITY_LOW ; sConfigOC . OCFastMode = TIM_OCFAST_DISABLE ; if ( HAL_TIM_PWM_ConfigChannel ( & htim3 , & sConfigOC , TIM_CHANNEL_2 ) != HAL_OK ) { Error_Handler ( ) ; } HAL_TIM_Base_Start ( & htim3 ) ; HAL_TIM_PWM_Start ( & htim3 , TIM_CHANNEL_2 ) ; HAL_TIM_MspPostInit ( & htim3 ) ; }
@brief TIM3 Initialization Function
 @param None
 @retval None
@brief TIM3 Initialization Function @param None @retval None
/* USER CODE BEGIN TIM3_Init 0 */ /* USER CODE END TIM3_Init 0 */ /* USER CODE BEGIN TIM3_Init 1 */ /* USER CODE END TIM3_Init 1 */ /* USER CODE BEGIN TIM3_Init 2 */ /* USER CODE END TIM3_Init 2 */