高级会员
- 积分
- 523
- 金钱
- 523
- 注册时间
- 2016-1-11
- 在线时间
- 132 小时
|
发表于 2018-5-17 19:32:53
|
显示全部楼层
 if(edge==RESET)//上升沿
                {
                       [b] rising=TIM5->CCR1-rising_last;
                        rising_last=TIM5->CCR1;
                        TIM_OC1PolarityConfig(TIM5,TIM_ICPolarity_Falling); //CC1P=0 设置为上升沿捕获
                        edge=SET;
                }
                else
                {
                        falling=TIM5->CCR1-rising_last;
                        TIM_OC1PolarityConfig(TIM5,TIM_ICPolarity_Rising); //CC1P=0 设置为上升沿捕获
                        edge=RESET;
               }
                sprintf(str,"Freq:%.2f Hz\nDuty:%.3f\n",90000000.0/rising,(float)falling/(float)rising);//频率、占空比??????????? 道友,在下请教。 你这个好像只能获取占空比吧?你用主频/rising 干嘛?/rising不是CCR1的前一个脉冲和后一个脉冲计数(cnt)的差值吗? |
|