找回密碼
 立即注冊

QQ登錄

只需一步,快速開始

搜索
查看: 1645|回復: 0
收起左側

STC單片機延時程序總結

[復制鏈接]
ID:579397 發(fā)表于 2023-3-3 02:52 | 顯示全部樓層 |閱讀模式
/*********************************************
                程序名稱        :延時函數(shù)
*********************************************/

//#define MAIN_Fosc 48000000L        //定義主時鐘
//#define MAIN_Fosc 44236800L        //定義主時鐘
//#define MAIN_Fosc 40000000L        //定義主時鐘
//#define MAIN_Fosc 36864000L        //定義主時鐘
//#define MAIN_Fosc 35000000L        //定義主時鐘
//#define MAIN_Fosc 33177600L        //定義主時鐘
//#define MAIN_Fosc 30000000L        //定義主時鐘
//#define MAIN_Fosc 27000000L        //定義主時鐘
//#define MAIN_Fosc 24000000L        //定義主時鐘
//#define MAIN_Fosc 22118400L        //定義主時鐘
//#define MAIN_Fosc 20000000L        //定義主時鐘
//#define MAIN_Fosc 18432000L        //定義主時鐘
#define MAIN_Fosc 12000000L        //定義主時鐘
//#define MAIN_Fosc 11059200L        //定義主時鐘
//#define MAIN_Fosc 6000000L        //定義主時鐘
//#define MAIN_Fosc 5529600L        //定義主時鐘

void Delay(unsigned int ms)                //注:ms_max=65536
        {
                unsigned int i;
                do
                        {
                                i=MAIN_Fosc/96000L;                //STC89_12T
//                                i=MAIN_Fosc/48000L;                //STC89_6T
//                                i=MAIN_Fosc/14000;                //STC12
//                                i=MAIN_Fosc/13000;                //STC15
//                                i=MAIN_Fosc/10000;                //STC8
//                                i=MAIN_Fosc/6030;                        //STC32
                                while(--i)        ;
                                }
                        while(--ms);
        }

評分

參與人數(shù) 1黑幣 +50 收起 理由
admin + 50 共享資料的黑幣獎勵!

查看全部評分

回復

使用道具 舉報

您需要登錄后才可以回帖 登錄 | 立即注冊

本版積分規(guī)則

手機版|小黑屋|51黑電子論壇 |51黑電子論壇6群 QQ 管理員QQ:125739409;技術交流QQ群281945664

Powered by 單片機教程網(wǎng)

快速回復 返回頂部 返回列表