📄 eeprom.lst
字号:
C51 COMPILER V7.05 EEPROM 03/14/2004 11:08:57 PAGE 1
C51 COMPILER V7.05, COMPILATION OF MODULE EEPROM
OBJECT MODULE PLACED IN eeprom.OBJ
COMPILER INVOKED BY: C:\KEIL\C51\BIN\C51.EXE eeprom.c BROWSE DEBUG OBJECTEXTEND
stmt level source
1 //eeprom.c - code recommendation for C header file
2 /***********************************************************************
3 MODULE: EEPROM
4 VERSION: 1.00
5 CONTAINS: Routines for accessing the EEPROM on the Philips
6 P89LPC932
7 COPYRIGHT: Embedded Systems Academy, Inc. - www.esacademy.com
8 LICENSE: May be freely used in commercial and non-commercial code
9 without royalties provided this copyright notice remains
10 in this file and unaltered
11 WARNING: IF THIS FILE IS REGENERATED BY CODE ARCHITECT ANY CHANGES
12 MADE WILL BE LOST. WHERE POSSIBLE USE ONLY CODE ARCHITECT
13 TO CHANGE THE CONTENTS OF THIS FILE
14 GENERATED: On "Mar 14 2004" at "11:02:25" by Code Architect 2.03
15 ***********************************************************************/
16
17 // SFR description needs to be included
18 #include<REG922.h>
19 #include "eeprom.h"
20
21 // flag that indicates if the EEPROM is busy or not
22 static bit meeprombusy;
23
24 /***********************************************************************
25 DESC: Initializes the EEPROM. Enables EEPROM interrupt
26 RETURNS: Nothing
27 CAUTION: Set EA to 1 after calling to enable all interrupts
28 ************************************************************************/
29 void eeprom_init
30 (
31 void
32 )
33 {
34 1 // initially eeprom is not busy
35 1 meeprombusy = 0;
36 1
37 1 // set isr priority to 0
38 1 IP1 &= 0x7F;
39 1 IP0H &= 0x7F;
40 1 // enable eeprom interrupt
41 1 EIEE = 1;
*** ERROR C202 IN LINE 41 OF EEPROM.C: 'EIEE': undefined identifier
42 1 }
43
44 /***********************************************************************
45 DESC: Reads a location in the EEPROM.
46 If either global interrupts or the EEPROM interrupt is disabled
47 then the function will return when the operation is complete.
48 If global interrupts and the EEPROM interrupt are enabled, the
49 function will return immediately and an interrupt will occur
50 when the operation is complete.
51 RETURNS: The 8-bit value read if interrupts are disabled, otherwise
52 0x00 will be returned.
53 CAUTION: eeprom_init must be called first
54 ************************************************************************/
C51 COMPILER V7.05 EEPROM 03/14/2004 11:08:57 PAGE 2
55 unsigned char eeprom_read
56 (
57 unsigned int address // 9-bit address to read (0x000 - 0x1FF)
58 )
59 {
60 1 // wait for previous operation to complete
61 1 while (meeprombusy);
62 1
63 1 // eeprom now busy
64 1 meeprombusy = 1;
65 1
66 1 // store bit 8 of address
67 1 // byte operation, clear interrupt flag
68 1 DEECON = (address >> 8) & 0x01;
*** ERROR C202 IN LINE 68 OF EEPROM.C: 'DEECON': undefined identifier
69 1 // store bits 0-7 of address
70 1 DEEADR = address & 0xFF;
*** ERROR C202 IN LINE 70 OF EEPROM.C: 'DEEADR': undefined identifier
71 1
72 1 // if not using interrupt then poll for end of operation
73 1 if (!EA || !EIEE)
*** ERROR C202 IN LINE 73 OF EEPROM.C: 'EIEE': undefined identifier
74 1 {
75 2 // wait for operation to complete
76 2 while (!(DEECON & 0x80));
*** ERROR C202 IN LINE 76 OF EEPROM.C: 'DEECON': undefined identifier
77 2 // eeprom no longer busy
78 2 meeprombusy = 0;
79 2 // return value
80 2 return DEEDAT;
*** ERROR C202 IN LINE 80 OF EEPROM.C: 'DEEDAT': undefined identifier
81 2 }
82 1
83 1 return 0x00;
84 1 }
85
86 /***********************************************************************
87 DESC: Writes to a location in the EEPROM.
88 If either global interrupts or the EEPROM interrupt is disabled
89 then the function will return when the operation is complete.
90 If global interrupts and the EEPROM interrupt are enabled, the
91 function will return immediately and an interrupt will occur
92 when the operation is complete.
93 RETURNS: Nothing
94 CAUTION: eeprom_init must be called first
95 ************************************************************************/
96 void eeprom_write
97 (
98 unsigned int address, // 9-bit address to write to (0x000 - 0x1FF)
99 unsigned char value // value to write
100 )
101 {
102 1 bit eacopy;
103 1
104 1 // wait for previous operation to complete
105 1 while (meeprombusy);
106 1
107 1 // eeprom now busy
108 1 meeprombusy = 1;
109 1
110 1 // store bit 8 of address
111 1 // byte operation, clear interrupt flag
C51 COMPILER V7.05 EEPROM 03/14/2004 11:08:57 PAGE 3
112 1 DEECON = (address >> 8) & 0x01;
*** ERROR C202 IN LINE 112 OF EEPROM.C: 'DEECON': undefined identifier
113 1 // disable interrupts
114 1 eacopy = EA;
115 1 EA = 0;
116 1 // store value to write
117 1 DEEDAT = value;
*** ERROR C202 IN LINE 117 OF EEPROM.C: 'DEEDAT': undefined identifier
118 1 // store bits 0-7 of address
119 1 DEEADR = address & 0xFF;
*** ERROR C202 IN LINE 119 OF EEPROM.C: 'DEEADR': undefined identifier
120 1 // restore interrupts
121 1 EA = eacopy;
122 1
123 1 // if not using interrupt then poll for end of operation
124 1 if (!EA || !EIEE)
*** ERROR C202 IN LINE 124 OF EEPROM.C: 'EIEE': undefined identifier
125 1 {
126 2 // wait for operation to complete
127 2 while (!(DEECON & 0x80));
*** ERROR C202 IN LINE 127 OF EEPROM.C: 'DEECON': undefined identifier
128 2 // eeprom no longer busy
129 2 meeprombusy = 0;
130 2 }
131 1 }
132
133 /***********************************************************************
134 DESC: Writes a value to every location in a 64-byte row in
135 the EEPROM.
136 If either global interrupts or the EEPROM interrupt is disabled
137 then the function will return when the operation is complete.
138 If global interrupts and the EEPROM interrupt are enabled, the
139 function will return immediately and an interrupt will occur
140 when the operation is complete.
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -