日本黄色一级经典视频|伊人久久精品视频|亚洲黄色色周成人视频九九九|av免费网址黄色小短片|黄色Av无码亚洲成年人|亚洲1区2区3区无码|真人黄片免费观看|无码一级小说欧美日免费三级|日韩中文字幕91在线看|精品久久久无码中文字幕边打电话

  • 當(dāng)前位置:首頁 > 單片機(jī) > 單片機(jī)
    [導(dǎo)讀]/************************************************************ 函數(shù)庫說明:ATMEGE8 延遲庫函數(shù)* 版本: v1.0 * **

    /***********************************************************

    * 函數(shù)庫說明:ATMEGE8 延遲庫函數(shù)

    * 版本: v1.0

    *

    ************************************************************

    *注意: LED PC5

    ***********************************************************/

    #include

    //定義外部晶振

    #define F_CPU 6000000UL

    //延遲包含頭文件

    #include

    //函數(shù)聲明

    void Delay_s(int ss);

    int main(void)

    {

    //LED等PC5設(shè)置為輸出

    DDRC |= (1 << DDC5);

    //起始PC5輸出高電平,LED不亮

    PORTC |= (1 << PC5);

    while(1)

    {

    //取反

    PORTC ^= (1 << PC5);

    //延遲1s

    Delay_s(1);

    }

    return 0;

    }

    /***********************************************************

    ** 名稱:void Delay_s(int ss)

    ** 功能:精確1s延遲

    ** 入口參數(shù):ss 需要延時的秒數(shù)

    ** 出口參數(shù):無

    ** 使用說明:系統(tǒng)庫函數(shù)延遲因晶振不同有大小限制

    ***********************************************************/

    void Delay_s(int ss)

    {

    int i = 0;

    while(ss--)

    {

    for(i = 0; i < 25; i++)

    {

    _delay_ms(40);

    }

    }

    }


    //首先庫文件里面不再定義F_CPU(即晶振頻率),所以在main.c中自行定義。

    //且系統(tǒng)延遲函數(shù)因晶振的不同對延遲大小有限制,需要注意:

    /**

    ingroup util_delay

    Perform a delay of c __us microseconds, using _delay_loop_1().

    The macro F_CPU is supposed to be defined to a

    constant defining the CPU clock frequency (in Hertz).

    The maximal possible delay is 768 us / F_CPU in MHz.

    */


    /**

    ingroup util_delay

    Perform a delay of c __ms milliseconds, using _delay_loop_2().

    The macro F_CPU is supposed to be defined to a

    constant defining the CPU clock frequency (in Hertz).

    The maximal possible delay is 262.14 ms / F_CPU in MHz.

    */


    本站聲明: 本文章由作者或相關(guān)機(jī)構(gòu)授權(quán)發(fā)布,目的在于傳遞更多信息,并不代表本站贊同其觀點(diǎn),本站亦不保證或承諾內(nèi)容真實(shí)性等。需要轉(zhuǎn)載請聯(lián)系該專欄作者,如若文章內(nèi)容侵犯您的權(quán)益,請及時聯(lián)系本站刪除( 郵箱:macysun@21ic.com )。
    換一批
    延伸閱讀
    關(guān)閉