C51全局初始化及精確延時(shí)程序,51單片機(jī)精確延時(shí)程序
關(guān)鍵字:單片機(jī)延時(shí)程序
/*********************************************************************************************************
* Initialization Program
* QiZhao,2007
* All Rights Reserved
* File : initial.h
* By : QiZhao
* Contact :zq1987731@163.com
*
* 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 :zq1987731@163.com
*
* 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)站授權(quán)轉(zhuǎn)載。文章觀點(diǎn)僅代表作者本人,不代表電子發(fā)燒友網(wǎng)立場(chǎng)。文章及其配圖僅供工程師學(xué)習(xí)之用,如有內(nèi)容侵權(quán)或者其他違規(guī)問題,請(qǐng)聯(lián)系本站處理。
舉報(bào)投訴
發(fā)布評(píng)論請(qǐng)先 登錄
相關(guān)推薦
熱點(diǎn)推薦
使用系統(tǒng)定時(shí)器SysTick來(lái)實(shí)現(xiàn)精確延時(shí)微秒和毫秒函數(shù)
*/return (0UL);/* Function successful */}通過(guò)后面的注釋也可以看出,這是對(duì)SysTick定時(shí)器進(jìn)行初始化,配置初始計(jì)數(shù)值,使能中斷,使能定時(shí)器等。對(duì)應(yīng)的中斷函數(shù)為
發(fā)表于 11-20 07:12
C語(yǔ)言和單片機(jī)C語(yǔ)言有什么差異
區(qū)別是由編譯器決的,只能參考對(duì)應(yīng)的編譯手冊(cè),即使同種平臺(tái)不同的編譯器對(duì)C的擴(kuò)展也有不同。
3、單片機(jī)c語(yǔ)言編程是基于C語(yǔ)言的單片機(jī)編程。
發(fā)表于 11-14 07:55
單片機(jī)怎么燒程序
單片機(jī)燒程序是將編寫好的程序代碼寫入單片機(jī)內(nèi)部存儲(chǔ)單元,讓單片機(jī)按照預(yù)設(shè)邏輯工作的過(guò)程,是單片機(jī)
AT89C51 單片機(jī)中文資料
電子發(fā)燒友網(wǎng)站提供《AT89C51 單片機(jī)中文資料.pdf》資料免費(fèi)下載
發(fā)表于 06-24 15:29
?1次下載
單片機(jī)原理及應(yīng)用
本書全面系統(tǒng)地介紹了 MCS-51 系列單片機(jī)的基本結(jié)構(gòu)、工作原理及應(yīng)用技術(shù)。主要內(nèi)容包括:微型計(jì)算機(jī)的基礎(chǔ)知識(shí)、MCS-51 單片機(jī)的基本結(jié)構(gòu)、匯編語(yǔ)言和
發(fā)表于 06-16 16:58
C51單片機(jī)及C語(yǔ)言知識(shí)點(diǎn)必備秘籍
單片機(jī)關(guān)鍵知識(shí)點(diǎn)一覽:
系列一
1:單片機(jī)簡(jiǎn)敘
2:單片機(jī)引腳介紹
3:單片機(jī)存儲(chǔ)器結(jié)構(gòu)
4:第一個(gè)單片機(jī)小
發(fā)表于 05-15 14:00
新概念51單片機(jī)C語(yǔ)言教程入門、提高、開發(fā)、拓展全攻略
1.6 單片機(jī)的C51基礎(chǔ)知識(shí)介紹
1.6.1 利用C語(yǔ)言開發(fā)單片機(jī)的優(yōu)點(diǎn)
1.6.2 C51中的基本數(shù)據(jù)類型
1.6.3
發(fā)表于 04-15 13:57
單片機(jī)學(xué)習(xí)—C51源代碼和Proteus仿真文件
單片機(jī)學(xué)習(xí)—C51源代碼和Proteus仿真文件.zip, 有各種例子
發(fā)表于 02-10 13:46
?2次下載
LDC1000是否需要在初始化之后延時(shí)才會(huì)開始測(cè)量呢?
想向您請(qǐng)教一個(gè)問題,LDC1000是什么時(shí)候開始測(cè)量呢,是初始化完成之后還是只要上電成功就行,或者是需要某些特殊的設(shè)置,是否需要在初始化之后延時(shí)才會(huì)開始測(cè)量呢?
發(fā)表于 01-13 06:19
如何通過(guò)總線來(lái)初始化ADS1256的寄存器?
我用STC89C52來(lái)驅(qū)動(dòng)ADS1256時(shí),發(fā)現(xiàn)需要用到SPI協(xié)議,單片機(jī)需要用IO口模擬SPI總線與ADS1256通信,但是我不知道如何通過(guò)總線來(lái)初始化ADS1256的寄存器,希望大家能給我提供一些代碼支持,
發(fā)表于 12-16 06:47

C51全局初始化及精確延時(shí)程序,51單片機(jī)精確延時(shí)程序
評(píng)論