diff --git a/Core/Inc/led.h b/Core/Inc/led.h index 31262e4..76494f7 100644 --- a/Core/Inc/led.h +++ b/Core/Inc/led.h @@ -11,7 +11,7 @@ void LED_Start(uint8_t led); void LED_Stop(uint8_t led); -// duty in [0, 100] +// duty in [0, 255] void LED_SetDuty(uint8_t r, uint8_t g, uint8_t b); #endif diff --git a/Core/Src/tim.c b/Core/Src/tim.c index f66b0a8..8761c77 100644 --- a/Core/Src/tim.c +++ b/Core/Src/tim.c @@ -1,21 +1,21 @@ /* USER CODE BEGIN Header */ /** - ****************************************************************************** - * @file tim.c - * @brief This file provides code for the configuration - * of the TIM instances. - ****************************************************************************** - * @attention - * - * Copyright (c) 2024 STMicroelectronics. - * All rights reserved. - * - * This software is licensed under terms that can be found in the LICENSE file - * in the root directory of this software component. - * If no LICENSE file comes with this software, it is provided AS-IS. - * - ****************************************************************************** - */ + ****************************************************************************** + * @file tim.c + * @brief This file provides code for the configuration + * of the TIM instances. + ****************************************************************************** + * @attention + * + * Copyright (c) 2024 STMicroelectronics. + * All rights reserved. + * + * This software is licensed under terms that can be found in the LICENSE file + * in the root directory of this software component. + * If no LICENSE file comes with this software, it is provided AS-IS. + * + ****************************************************************************** + */ /* USER CODE END Header */ /* Includes ------------------------------------------------------------------*/ #include "tim.h" @@ -43,9 +43,9 @@ void MX_TIM2_Init(void) /* USER CODE END TIM2_Init 1 */ htim2.Instance = TIM2; - htim2.Init.Prescaler = 72 - 1; + htim2.Init.Prescaler = 0; htim2.Init.CounterMode = TIM_COUNTERMODE_UP; - htim2.Init.Period = 1 - 1; + htim2.Init.Period = 72 - 1; htim2.Init.ClockDivision = TIM_CLOCKDIVISION_DIV1; htim2.Init.AutoReloadPreload = TIM_AUTORELOAD_PRELOAD_DISABLE; if (HAL_TIM_Base_Init(&htim2) != HAL_OK) @@ -84,9 +84,9 @@ void MX_TIM3_Init(void) /* USER CODE END TIM3_Init 1 */ htim3.Instance = TIM3; - htim3.Init.Prescaler = 72 - 1; + htim3.Init.Prescaler = 720 - 1; htim3.Init.CounterMode = TIM_COUNTERMODE_UP; - htim3.Init.Period = 100 - 1; + htim3.Init.Period = 256 - 1; htim3.Init.ClockDivision = TIM_CLOCKDIVISION_DIV1; htim3.Init.AutoReloadPreload = TIM_AUTORELOAD_PRELOAD_DISABLE; if (HAL_TIM_Base_Init(&htim3) != HAL_OK) @@ -109,7 +109,7 @@ void MX_TIM3_Init(void) Error_Handler(); } sConfigOC.OCMode = TIM_OCMODE_PWM1; - sConfigOC.Pulse = 10000 - 1; + sConfigOC.Pulse = 255; sConfigOC.OCPolarity = TIM_OCPOLARITY_HIGH; sConfigOC.OCFastMode = TIM_OCFAST_DISABLE; if (HAL_TIM_PWM_ConfigChannel(&htim3, &sConfigOC, TIM_CHANNEL_2) != HAL_OK)