?? chip.lst
字號:
C51 COMPILER V7.06 CHIP 10/13/2006 09:21:08 PAGE 1
C51 COMPILER V7.06, COMPILATION OF MODULE CHIP
OBJECT MODULE PLACED IN chip.OBJ
COMPILER INVOKED BY: C:\Keil\C51\BIN\C51.EXE chip.c LARGE BROWSE DEBUG OBJECTEXTEND
stmt level source
1 #include <./Atmel/at89x52.h>
2 #include <stdio.h>
3 #include "source.h"
4 #include <intrins.h>
5 #include <absacc.h>
6 //_nop_(); 在fosc=18.432MHZ時(shí),一個(gè)空語句是 0.65us
7 void delay_macnine_ncircle(unsigned char cnt){//11+6*cnt machin circle.
8 1 while(cnt--);
9 1 }
10 void delay_10us(unsigned char tus){//在晶振頻率為18.432MHZ時(shí)延時(shí)10微秒的函數(shù)
11 1 tus--;
12 1 while(tus--){
13 2 _nop_();_nop_();_nop_();
14 2 _nop_();_nop_();_nop_();
15 2 _nop_();_nop_();_nop_();
16 2 }
17 1 }
18 /*因?yàn)锳T24C4的最大速率為100k,所以需要延時(shí)*/
19 #define DELAY _nop_();_nop_();_nop_();_nop_();_nop_();_nop_();_nop_();_nop_();_nop_();_nop_();_nop_();_nop
-_();_nop_();_nop_();_nop_();_nop_();_nop_();_nop_();_nop_();_nop_()
20 #define I2CDATA SDA /*for read data from bit port*/
21 #define I2CSETDATA SDA=1 /*sda=1 macro*/
22 #define I2CCLRDATA SDA=0 /*sda=0 macro*/
23 #define I2CSETCLK SCL=1 /*scl=1 macro*/
24 #define I2CCLRCLK SCL=0 /*scl=0 macro*/
25
26 #define i2c_start AT24C64_start
27 #define i2c_stop AT24C64_stop
28 #define i2c_write_byte AT24C64_write_byte
29 #define i2c_read_byte AT24C64_read_byte
30 #define i2c_wait_ack AT24C64_wait_ack
31 #define i2c_send_ack AT24C64_send_ack
32 #define i2c_send_notack AT24C64_send_notack
33 /***以下的函數(shù)與SDA2000的操作是一樣的,而使用的端口也是一樣的***/
34 void i2c_start(){
35 1 I2CSETDATA;
36 1 I2CSETCLK;
37 1 DELAY;
38 1 I2CCLRDATA;
39 1 DELAY;
40 1 I2CCLRCLK;
41 1 }
42 void i2c_stop(){
43 1 I2CCLRCLK;
44 1 I2CCLRDATA;
45 1 DELAY;
46 1 I2CSETCLK;
47 1 DELAY;
48 1 I2CSETDATA;
49 1 }
50 void i2c_write_byte(unsigned char ch)
51 {
52 1 unsigned char i=8;
53 1 while(i--){
54 2 I2CCLRCLK;_nop_();
C51 COMPILER V7.06 CHIP 10/13/2006 09:21:08 PAGE 2
55 2 if(ch&0x80)
56 2 I2CSETDATA;
57 2 else
58 2 I2CCLRDATA;
59 2 ch<<=1;DELAY;
60 2 I2CSETCLK;DELAY;
61 2 }
62 1 I2CCLRCLK;
63 1 }
64
65 unsigned char i2c_read_byte(void)
66 {
67 1 unsigned char i=8;
68 1 unsigned char ddata=0;
69 1 I2CSETDATA ;
70 1 while (i--){
71 2 ddata<<=1 ;
72 2 I2CCLRCLK;DELAY;
73 2 I2CSETCLK;DELAY;
74 2 ddata|=I2CDATA;
75 2 }
76 1 I2CCLRCLK;
77 1 return ddata;
78 1 }
79 bit i2c_wait_ack(void)
80 {
81 1 unsigned char errtime=255;//因故障接收方無ACK 超時(shí)值為255
82 1 I2CSETDATA;DELAY;
83 1 I2CSETCLK ;DELAY;
84 1 while(I2CDATA){
85 2 errtime--;
86 2 if (!errtime){
87 3 i2c_stop();
88 3 return 0;
89 3 }
90 2 }
91 1 I2CCLRCLK;
92 1 return 1;
93 1 }
94 void i2c_send_ack(void)
95 {
96 1 I2CCLRDATA; DELAY;
97 1 I2CSETCLK; DELAY;
98 1 I2CCLRCLK;
99 1 }
100
101 void i2c_send_notack(void)
102 {
103 1 I2CSETDATA ; DELAY;
104 1 I2CSETCLK ; DELAY;
105 1 I2CCLRCLK;
106 1 }
107 /***因?yàn)锳T24C64與SDA2000共用同樣的CPU管腳,其區(qū)分對不同芯片的操作是使用設(shè)備類型**/
108 /***來區(qū)分的,如EEPROM的地址為0xa,而SDA2000的設(shè)備地址為0x6*/
109 #define DEVICEAW 0Xa0
110 #define DEVICEAR 0Xa1
111 void AT24C64_wbytes(unsigned char *add,unsigned char len,unsigned char *buf){//向EEPROM中寫數(shù)據(jù),最長為32
?? 快捷鍵說明
復(fù)制代碼
Ctrl + C
搜索代碼
Ctrl + F
全屏模式
F11
切換主題
Ctrl + Shift + D
顯示快捷鍵
?
增大字號
Ctrl + =
減小字號
Ctrl + -