追加更新:频率输出精度提高(添加四舍五入取整)
This commit is contained in:
parent
2cd09e4902
commit
8074b96f75
|
@ -38,7 +38,7 @@ extern "C" {
|
|||
HAL_TIMEx_PWMN_Stop(&htim1, TIM_CHANNEL_2); \
|
||||
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_AUTORELOAD(&htim1, duty -1); \
|
||||
HAL_TIMEx_PWMN_Start(&htim1, TIM_CHANNEL_2); \
|
||||
|
|
File diff suppressed because it is too large
Load Diff
Loading…
Reference in New Issue