标题: 51单片机 频率输出程序 [打印本页]

作者: Maca-1    时间: 2017-11-8 12:37
标题: 51单片机 频率输出程序
要求p2.1输出频率,多谢指教
频率
480HZ
周期
T=0.00208S
上升沿
T1=0.001386S
下降沿
T2=0.00069S
占空比
66.67%

下面程序行得通吗?
sbit PULSEP14 = P2^1;
void PulesOutP14()
{
        static unsigned int cntout = 0;
        if(cntout < 139)
                PULSEP14 = 1;
        else
                PULSEP14 = 0;
        cntout++;
        if(cntout >= 208)
                cntout = 0;
}

/*
0  -->  1  -->  2  -->  3  -->  4
----------------\________________
*/






欢迎光临 (http://www.51hei.com/bbs/) Powered by Discuz! X3.1