⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 initial.h

📁 极其强大的51单片机驱动128*64液晶C51程序
💻 H
字号:
/*********************************************************************************************************
*                                          Initialization Program
*                                               QiZhao,2007
*                                           All Rights Reserved
* File      : initial.h
* By        : QiZhao
* Contact   : zq1987731@163.com
*
* Version   : V2.2 γ
* 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_

/*********************************************************************************************************
*
*                                         Global macro definitions
*
*********************************************************************************************************/

    #include    <reg52.h>               // AT89S52
    #include    <absacc.h>              // Absolute address access
    #include    <string.h>              // Related to the string
    #include    <intrins.h>             // Related to Assembly Language
    #include    <ctype.h>               // Unicode conversion
    #include    <math.h>                // Mathematics functions packet
    #include    <stdio.h>               // Standard input or output
    #include    <stdlib.h>              // Memory Management

    #define bool    bit                 // Boolean variable
    #define uchar   unsigned char
    #define uint    unsigned int
    #define ulong   unsigned long

    #define TRUE    1
    #define FALSE   0
    #define NOP     _nop_();
    #define FOSC    12000000UL          // The frequency of crystal (Hz)

/*********************************************************************************************************
*
*                                          Accurate delay(5us)
*
*********************************************************************************************************/

    void delay5us (void)                // FOSC--12000000Hz
    {
        NOP
    }

/*********************************************************************************************************
*
*                                          Accurate delay(1ms~255ms)
*
*********************************************************************************************************/

    #define WAITE_HI  (FOSC / 2 / 12 / 1000 >> 8 )
    #define WAITE_LOW (FOSC / 2 / 12 / 1000 & 0xFF)

    void delayms (uchar time)
    {
        do
        {
            uchar j;

            #if WAITE_HI != 0
                j = 0;
                {
                    uchar i;
                    for (i = WAITE_HI; i > 0; i--)
                    {
                        while (--j);
                    }
                }
            #endif

            #if WAITE_LOW != 0
                j = WAITE_LOW;
                while (--j);
            #endif

        }while (--time);
    }

/*********************************************************************************************************
*
*                                            Includes not repeat
*
*********************************************************************************************************/

    #endif

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -