標(biāo)題: 51單片機 頻率輸出程序 [打印本頁]

作者: Maca-1    時間: 2017-11-8 12:37
標(biāo)題: 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.torrancerestoration.com/bbs/) Powered by Discuz! X3.1