Page 61 - MDP2022-2
P. 61

static  void  MX_TIM4_Init(void)
            {


                /*  USER  CODE  BEGIN  TIM4_Init  0  */

                /*  USER  CODE  END  TIM4_Init  0  */

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

                /*  USER  CODE  BEGIN  TIM4_Init  1  */

                /*  USER  CODE  END  TIM4_Init  1  */
                htim4.Instance  =  TIM4;
                htim4.Init.Prescaler  =  9000-1;
                htim4.Init.CounterMode  =  TIM_COUNTERMODE_UP;
                htim4.Init.Period  =  10-1;
                htim4.Init.ClockDivision  =  TIM_CLOCKDIVISION_DIV1;
                htim4.Init.AutoReloadPreload  =  TIM_AUTORELOAD_PRELOAD_DISABLE;
                if  (HAL_TIM_Base_Init(&htim4)  !=  HAL_OK)
                {
                    Error_Handler();
                }
                sClockSourceConfig.ClockSource  =  TIM_CLOCKSOURCE_INTERNAL;
                if  (HAL_TIM_ConfigClockSource(&htim4,  &sClockSourceConfig)  !=  HAL_OK)
                {
                    Error_Handler();
                }
                if  (HAL_TIM_PWM_Init(&htim4)  !=  HAL_OK)
                {
                    Error_Handler();
                }
                sMasterConfig.MasterOutputTrigger  =  TIM_TRGO_RESET;
                sMasterConfig.MasterSlaveMode  =  TIM_MASTERSLAVEMODE_DISABLE;
                if  (HAL_TIMEx_MasterConfigSynchronization(&htim4,  &sMasterConfig)  !=  HAL_OK)
                {
                    Error_Handler();
                }
                sConfigOC.OCMode  =  TIM_OCMODE_PWM1;
                sConfigOC.Pulse  =  0;
                sConfigOC.OCPolarity  =  TIM_OCPOLARITY_HIGH;
                sConfigOC.OCFastMode  =  TIM_OCFAST_DISABLE;
                if  (HAL_TIM_PWM_ConfigChannel(&htim4,  &sConfigOC,  TIM_CHANNEL_1)  !=  HAL_OK)
                {
                    Error_Handler();
                }
                /*  USER  CODE  BEGIN  TIM4_Init  2  */

                /*  USER  CODE  END  TIM4_Init  2  */
                HAL_TIM_MspPostInit(&htim4);

            }

            /**
                *  @brief  GPIO  Initialization  Function
   56   57   58   59   60   61   62   63   64   65   66