追加更新:频率输出精度提高(添加四舍五入取整)

This commit is contained in:
吴俊潮 2025-04-07 10:44:07 +08:00
parent 2cd09e4902
commit 8074b96f75
2 changed files with 7704 additions and 7704 deletions

View File

@ -38,7 +38,7 @@ extern "C" {
HAL_TIMEx_PWMN_Stop(&htim1, TIM_CHANNEL_2); \ HAL_TIMEx_PWMN_Stop(&htim1, TIM_CHANNEL_2); \
return; \ return; \
} \ } \
int32_t duty = FREQ_SYS / FREQ; \ int32_t duty = ( (float32)FREQ_SYS / (float32)FREQ + (float32)0.5 ); \
__HAL_TIM_SET_COMPARE(&htim1, TIM_CHANNEL_2, duty *PULSE / 100 - 1); \ __HAL_TIM_SET_COMPARE(&htim1, TIM_CHANNEL_2, duty *PULSE / 100 - 1); \
__HAL_TIM_SET_AUTORELOAD(&htim1, duty -1); \ __HAL_TIM_SET_AUTORELOAD(&htim1, duty -1); \
HAL_TIMEx_PWMN_Start(&htim1, TIM_CHANNEL_2); \ HAL_TIMEx_PWMN_Start(&htim1, TIM_CHANNEL_2); \

File diff suppressed because it is too large Load Diff