C51全局初始化及精確延時程序,51單片機精確延時程序
關鍵字:單片機延時程序
/*********************************************************************************************************
* Initialization Program
* QiZhao,2007
* All Rights Reserved
* File : initial.h
* By : QiZhao
* Contact :[email protected]
*
* Version : V2.1 γ
* Corrector : QiZhao
* Date : 2008.2.1 (Last modified)
*
* Remarks : Common set of macro definitions keyword, and by setting controlled
* crystal oscillator frequency precision delay subroutine.
*
*********************************************************************************************************/
* Initialization Program
* QiZhao,2007
* All Rights Reserved
* File : initial.h
* By : QiZhao
* Contact :[email protected]
*
* Version : V2.1 γ
* Corrector : QiZhao
* Date : 2008.2.1 (Last modified)
*
* Remarks : Common set of macro definitions keyword, and by setting controlled
* crystal oscillator frequency precision delay subroutine.
*
*********************************************************************************************************/
#ifndef _initial_h_
#define _initial_h_
#define _initial_h_
/*********************************************************************************************************
*
* Global macro definitions
*
*********************************************************************************************************/
#include // AT89S52
#include // Absolute address access
#include // Related to the string
#include // Related to Assembly Language
#include // Unicode conversion
#include // Mathematics functions packet
#include // Standard input or output
#include // Memory Management
*
* Global macro definitions
*
*********************************************************************************************************/
#include
#include // Absolute address access
#include
#include
#include
#include
#include
#include
#define TRUE 1
#define FALSE 0
#define bool bit // Boolean variable
#define uchar unsigned char
#define uint unsigned int
#define ulong unsigned long
#define FALSE 0
#define bool bit // Boolean variable
#define uchar unsigned char
#define uint unsigned int
#define ulong unsigned long
#define FOSC 12000000UL // The frequency of crystal
#define NOP _nop_();
#define NOP _nop_();
/*********************************************************************************************************
*
* Accurate delay(5us,10us)
*
*********************************************************************************************************/
*
* Accurate delay(5us,10us)
*
*********************************************************************************************************/
void delay10us (void) // FOSC->12000000
{
NOP
NOP
NOP
NOP
NOP
NOP
}
{
NOP
NOP
NOP
NOP
NOP
NOP
}
void delay5us (void) // FOSC->12000000
{
NOP
}
{
NOP
}
/*********************************************************************************************************
*
* Accurate delay(1ms~255ms)
*
*********************************************************************************************************/
*
* Accurate delay(1ms~255ms)
*
*********************************************************************************************************/
#define WAITE_HI (FOSC / 2 / 12 / 1000 >> 8 )
#define WAITE_LOW (FOSC / 2 / 12 / 1000 & 0xFF)
#define WAITE_LOW (FOSC / 2 / 12 / 1000 & 0xFF)
void delayms (uchar time)
{
do
{
uchar j;
{
do
{
uchar j;
#if WAITE_HI != 0
j = 0;
{
uchar i;
for(i = WAITE_HI; i > 0; i--)
{
while (--j);
}
}
#endif
j = 0;
{
uchar i;
for(i = WAITE_HI; i > 0; i--)
{
while (--j);
}
}
#endif
#if WAITE_LOW != 0
j = WAITE_LOW;
while (--j);
#endif
j = WAITE_LOW;
while (--j);
#endif
}while (--time);
}
}
/*********************************************************************************************************
*
* Includes not repeat
*
*********************************************************************************************************/
*
* Includes not repeat
*
*********************************************************************************************************/
#endif
聲明:本文內(nèi)容及配圖由入駐作者撰寫或者入駐合作網(wǎng)站授權轉載。文章觀點僅代表作者本人,不代表電子發(fā)燒友網(wǎng)立場。文章及其配圖僅供工程師學習之用,如有內(nèi)容侵權或者其他違規(guī)問題,請聯(lián)系本站處理。
舉報投訴
發(fā)布評論請先 登錄
相關推薦
熱點推薦
新概念51單片機C語言教程入門、提高、開發(fā)、拓展全攻略
1.6 單片機的C51基礎知識介紹
1.6.1 利用C語言開發(fā)單片機的優(yōu)點
1.6.2 C51中的基本數(shù)據(jù)類型
1.6.3
發(fā)表于 04-15 13:57
如何通過總線來初始化ADS1256的寄存器?
我用STC89C52來驅動ADS1256時,發(fā)現(xiàn)需要用到SPI協(xié)議,單片機需要用IO口模擬SPI總線與ADS1256通信,但是我不知道如何通過總線來初始化ADS1256的寄存器,希望大家能給我提供一些代碼支持,
發(fā)表于 12-16 06:47
基于51單片機的手動數(shù)字時鐘
具體實現(xiàn)功能由51單片機+8位共陰數(shù)碼管+獨立按鍵構成。具體功能:(1)利用數(shù)碼管顯示時分秒,顯示格式為“時-分-秒”;(2)利用6個按鍵控制時、分、秒,設定好后自動開始時鐘顯示;(3)設置秒復位

基于51單片機的遙控開關仿真(雙機通信)
靈活、高效的解決方案。本設計所使用的芯片可兼容以下所有的51系列單片機(包括AT系列和STC系列)。資料內(nèi)容仿真實現(xiàn)(protues8.7)本設計利用protues8.7軟件實現(xiàn)仿真設計,具體如圖。程序

基于51單片機的LED點陣滾動顯示系統(tǒng)
花樣;(4)可以利用“點陣LED字模生成工具”生成自己想要顯示的字符。仿真演示視頻:基于51單片機的LED點陣滾動顯示系統(tǒng)-仿真視頻設計介紹51單片機簡介

把esp8266加入到c51單片機單通道程序怎么寫
引腳。 VCC :連接到C51單片機的5V電源。 GND :連接到C51單片機的地線。 步驟 2:初始化串行通信 在
51系列單片機復位的作用是什么
51系列單片機是一種廣泛應用的微控制器,其復位功能對于系統(tǒng)的穩(wěn)定運行至關重要。 一、51系列單片機復位的作用 系統(tǒng)初始化 當
基于51單片機數(shù)字時鐘鬧鐘設計
本資源內(nèi)容概要:? ? ? ?這是基于51單片機數(shù)字時鐘鬧鐘設計包含了PDF版本電路圖、C語言程序源代碼(keil軟件打開)、proteus仿真。本資源適合人群:? ? ?
發(fā)表于 06-25 10:17
?0次下載
基于51單片機矩陣鍵盤音樂電子琴電路圖proteus仿真及程序
本資源內(nèi)容概要:? ? ? ?這是基于51單片機矩陣鍵盤音樂電子琴電路圖proteus仿真及程序設計包含了電路圖源文件(Altiumdesigner軟件打開)、C語言
發(fā)表于 06-21 14:32
?4次下載
基于51單片機分立器件超聲波測距電路圖及程序元件清單
本資源內(nèi)容概要:? ? ? ?這是基于51單片機分立器件超聲波測距電路圖及程序設計包含了電路圖源文件(Altiumdesigner軟件打開)、C語言
發(fā)表于 06-20 16:17
?0次下載
基于51單片機8路搶答器電路圖proteus仿真及程序
本資源內(nèi)容概要:? ? ? ?這是基于51單片機8路搶答器電路圖proteus仿真及程序設計包含了電路圖源文件(Altiumdesigner軟件打開)、C語言
發(fā)表于 06-19 14:15
?1次下載
基于51單片機16路搶答器電路圖及程序元件清單
本資源內(nèi)容概要:? ? ? ?這是基于51單片機16路搶答器電路圖及程序設計包含了電路圖源文件(Altiumdesigner軟件打開)、C語言程序
發(fā)表于 06-19 11:38
?2次下載
第五講:51單片機+RA8889驅動控制彩屏 完整源碼說明 【 源碼v1.2 】
P1.4SCS RA8889片選
P1.3SDO接RA8889的SDO
P1.2SDI 接RA8889的SDI
P1.1SCK SPI時鐘
【v1.0 程序功能】
51單片機采用STC89C
發(fā)表于 06-13 17:23
評論