C51全局初始化及精確延時程序,51單片機精確延時程序
關(guān)鍵字:單片機延時程序
/*********************************************************************************************************
* 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)載。文章觀點僅代表作者本人,不代表電子發(fā)燒友網(wǎng)立場。文章及其配圖僅供工程師學(xué)習(xí)之用,如有內(nèi)容侵權(quán)或者其他違規(guī)問題,請聯(lián)系本站處理。
舉報投訴
發(fā)布評論請先 登錄
相關(guān)推薦
熱點推薦
新概念51單片機C語言教程入門、提高、開發(fā)、拓展全攻略
1.6 單片機的C51基礎(chǔ)知識介紹
1.6.1 利用C語言開發(fā)單片機的優(yōu)點
1.6.2 C51中的基本數(shù)據(jù)類型
1.6.3
發(fā)表于 04-15 13:57
單片機學(xué)習(xí)—C51源代碼和Proteus仿真文件
單片機學(xué)習(xí)—C51源代碼和Proteus仿真文件.zip, 有各種例子
發(fā)表于 02-10 13:46
?1次下載
如何通過總線來初始化ADS1256的寄存器?
我用STC89C52來驅(qū)動ADS1256時,發(fā)現(xiàn)需要用到SPI協(xié)議,單片機需要用IO口模擬SPI總線與ADS1256通信,但是我不知道如何通過總線來初始化ADS1256的寄存器,希望大家能給我提供一些代碼支持,
發(fā)表于 12-16 06:47
51單片機中為什么很少出現(xiàn)printf的身影
51單片機中為什么很少出現(xiàn) printf 的身影?是用不了嗎? 不是的,51單片機可以用 printf,只是不建議使用。 平時我們在操作系統(tǒng)上寫C

基于51單片機的7人多數(shù)投票表決器設(shè)計
基于51單片機的7人多數(shù)投票表決器設(shè)計 ( proteus仿真+程序+設(shè)計報告+講解視頻) 仿真圖proteus8.16(有低版本) 程序編譯器:keil 4/keil 5 編程語言:

基于51單片機的手動數(shù)字時鐘
具體實現(xiàn)功能由51單片機+8位共陰數(shù)碼管+獨立按鍵構(gòu)成。具體功能:(1)利用數(shù)碼管顯示時分秒,顯示格式為“時-分-秒”;(2)利用6個按鍵控制時、分、秒,設(shè)定好后自動開始時鐘顯示;(3)設(shè)置秒復(fù)位

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

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

把esp8266加入到c51單片機單通道程序怎么寫
引腳。 VCC :連接到C51單片機的5V電源。 GND :連接到C51單片機的地線。 步驟 2:初始化串行通信 在
51系列單片機復(fù)位的作用是什么
51系列單片機是一種廣泛應(yīng)用的微控制器,其復(fù)位功能對于系統(tǒng)的穩(wěn)定運行至關(guān)重要。 一、51系列單片機復(fù)位的作用 系統(tǒng)初始化 當(dāng)
評論