int main(void)
{
u8 dir=1;
u16 led0pwmval=0;
HAL_Init();
Stm32_Clock_Init(360,25,2,8);
delay_init(180);
uart_init(115200);
LED_Init();
TIM3_PWM_Init(500-1,90-1);
while(1)
{
delay_ms(10);
if(dir)led0pwmval++;
else led0pwmval--;
if(led0pwmval>300)dir=0;
if(led0pwmval==0)dir=1;
TIM_SetTIM3Compare4(led0pwmval);
}
}
void TIM_SetTIM3Compare4(u32 compare)
{
TIM3->CCR4=compare;
}
这个函数是怎样调节占空比的呢
一周热门 更多>