/* Set the Capture Compare Register value */
TIMx->CCR2 = TIM_OCInitStruct->TIM_Pulse;
void TIM_SetCompare2(TIM_TypeDef* TIMx, uint16_t Compare2)
{
/* Check the parameters */
assert_param(IS_TIM_LIST6_PERIPH(TIMx));
/* Set the Capture Compare2 Register value */
TIMx->CCR2 = Compare2;
}
由Stm32f10x_tim.c中的這兩處比較發現,
TIM_Pulse和Compare2都同樣指向TIMx->CCR2,所以這兩處都可以用來設置PWM的佔空比。
TIM_Pulse一般是在初始化時候用的。
函數TIM_SetCompare2 ,一般是在運行中修改用的。