中级会员
- 积分
- 231
- 金钱
- 231
- 注册时间
- 2013-9-9
- 在线时间
- 21 小时
|
我做了一个读取TIM1_CCR1H,TIM1_CCR1L值,直接+1,-1,做渐明渐暗。发现一个问题?减到0后,灯不是灭的。一定要单独清把TIM1_CCR1H,TIM1_CCR1L 为0才行。
//test
TIM1_CCR1H = 0;
TIM1_CCR1L = 0;
while(1)
{
L_yy:
if(++TIM1_CCR1L == 0)
{
TIM1_CCR1H++;
}
if((TIM1_CCR1H == 7) && (TIM1_CCR1L == 0xd0))
{
while(1)
{
if(--TIM1_CCR1L == 0)
{
TIM1_CCR1H--;
}
if((TIM1_CCR1H == 0) && (TIM1_CCR1L == 0x0))
{
TIM1_CCR1H = 0;
TIM1_CCR1L = 0; 不清0,灯不灭。
delayms(900);
delayms(900);
delayms(900);
delayms(900);
delayms(900);
delayms(900);
temp1 = TIM1_CCR1L;
temp1 += 1;
temp = TIM1_CCR1H;
goto L_yy;
}
delayms(1);
}
}
delayms(1);
}
|
|