新手请教!
CLK_PeripheralClockConfig(CLK_Peripheral_TIM2, ENABLE);
GPIO_Init(GPIOB,GPIO_Pin_0,GPIO_Mode_Out_PP_High_Fast);
TIM2->CCMR1 = TIM2->CCMR1 | 0x70;
TIM2->CCER1 = TIM2->CCER1 | 0x03;
TIM2->ARRH = 0;
TIM2->ARRL = 0xFF;
TIM2->CCR1H = 0;
TIM2->CCR1L = 0;
TIM2->PSCR = 0;
TIM2->CR1 =TIM2->CR1 | 0x01;
while (1)
{
unsigned char i;
for(i=0;i<128;i++)
{
TIM1->CCR1H = 0;
TIM1->CCR1L = i;
delay_10us(500);
}
for(i=128;i>0;i--)
{
TIM1->CCR1H = 0;
TIM1->CCR1L = i;
delay_10us(500);
}
}
}
友情提示: 此问题已得到解决,问题已经关闭,关闭后问题禁止继续编辑,回答。
一周热门 更多>