SOGO論壇

標題: 8051程式問題 [列印本頁]

作者: a7880330    時間: 2012-9-13 11:59:15     標題: 8051程式問題

請問各位前輩!!
有谁可以跟我說這幾行的意義!!
#include <reg51.h> -這行我知道大約是"使用89S51在此以後皆檔名使用"regx51.h""
#include <intrins.h> -這行我不太了解了~我知道他在定義但他大約定義哪幾個什麼!!
#include <stdio.h>  -這行沒問題
#include "1602.H"   -之後開始我就看不太懂了!!
#define INT8U unsigned char
#define INT16U unsigned int

#define WRITE_BURST 0x40 //连续写入
#define READ_SINGLE 0x80 //读
#define READ_BURST 0xC0 //连续读
#define BYTES_IN_RXFIFO 0x7F //接收缓冲区的有效字节数
#define CRC_OK 0x80 //CRC校验通过位标志


作者: if8051    時間: 2012-9-13 17:25:06

# 帶頭表示 preprocessor 前置處理器有 4 大功能:

1 : #include <at89x52.h> 含括 at89x52.h 這個檔案進來,在 \ INC 這個目錄底下可以找到該檔案,ATMEL AT89S52
所有暫存器映射 map 為同名的變數,對這些變數的讀寫,相當於對暫存器的讀寫 access 。

2 : #define  PI  3.1415926 取代指令,往後遇上 PI 就以 3.1415926 取代;#define  doubleX(x)  ((x) + (x))  macro
巨集指令, doubleX(6) 得到是 6 + 6 = 12

3 : #if   #else   #elif   #ifdef   #ifndef   #endif   條件式編譯

4 : #pragma 執行編譯器的命令

留意  #include  <at89x52.h>  後不必加 ; 分號,因為 preprocessor 是對 compiler 下命令。
P0 = 0x0F;  這 statement 是對 MCU 8051 CPU 下命令,所以要用  ; 分號   當做此 statement 結束。

#include <intrins.h>
intrins.h    這標頭檔是 Keil 幫我們寫好的 function,#include <intrins.h> 就可以使用 _nop_ (); _cror_ (P0,1);
The intrins.h include file contains prototypes for routines that instruct the compiler to generate intrinsic code.

_chkfloat_
_crol_
_cror_
_irol_
_iror_
_nop_
_pop_
_push_
_testbit_

詳閱 Keil C IDE Help \ Open Books Window \ Tools User's Guide \ Cx51 Compiler User's Guide \ Library Reference

#include "1602.H" 此行表示 1602.H 是作者自己撰寫的 header file 標頭檔存放在目前的目錄底下,這是 16 * 2  LCD 模組相
關記憶體位址及資料,這是原作者自己定義的,外人不得而知。

#define INT8U unsigned char 前面已說過了,往後出現 INT8U 將以 unsigned char 取代的意思。





歡迎光臨 SOGO論壇 (https://oursogo.com/) Powered by OURSOGO.COM