📄 eeprom.lst
字号:
ANSI-C/cC++ Compiler for HC12 V-5.0.24 Build 4047, Feb 17 2004
1: /******************************************************************************
2: * COPYRIGHT (c) MOTOROLA 2002
3: * FILE NAME: eeprom.c REVISION R1B
4: *
5: * PURPOSE: This module handles all tasks related to internal EEPROM module
6: *
7: *******************************************************************************
8: *******************************************************************************
9: ** THIS CODE IS ONLY INTENDED AS AN EXAMPLE FOR THE METROWERKS COMPILER AND **
10: ** THE HCS 12 EVB AND HAS ONLY BEEN GIVEN A MIMIMUM LEVEL OF TEST. **
11: ** IT IS PROVIDED 'AS SEEN' WITH NO GUARANTEES AND NO PROMISE OF SUPPORT. **
12: *******************************************************************************
13: *******************************************************************************
14: *
15: * DOCUMENTATION SOURCE: Motorola TSPG 8/16 MCU bit Division (HKG)
16: *
17: * TARGET DEVICE: Hardware EVB912DP256 or equivalent
18: *
19: * INCLUDE FILES: <hidef.h>
20: * "com.h"
21: * "DP256Port.h"
22: *
23: * FUNCTIONS : eeprom_erase_cmd
24: * eeprom_program_cmd
25: * eeprom_program
26: * eeprom_erase
27: *
28: * COMPILER: Metrowerks VERSION: ADS v1.2
29: *
30: * DESCRIPTION: Program to control the EEPROM module
31: *
32: * INPUTS
33: * ------
34: * All commands are inovked by PC Hyperterminal via SCI0.
35: *
36: * NOTES
37: * -----
38: * All modules remain at their reset addresses.
39: *
40: *
41: * UPDATE HISTORY
42: * REV AUTHOR DATE DESCRIPTION OF CHANGE
43: * --- ------ --------- ---------------------
44: * R1A r29566 02/04/20 Initial version
45: * R1B r29566 02/07/12 Demo version
46: *
47: ******************************************************************************/
48: /*===============================a============================================*/
49: /* Motorola reserves the right to make changes without further notice to any */
50: /* product herein to improve reliability, function, or design. Motorola does */
51: /* not assume any liability arising out of the application or use of any */
52: /* product, circuit, or software described herein; neither does it convey */
53: /* any license under its patent rights nor the rights of others. Motorola */
54: /* products are not designed, intended, or authorized for use as components */
55: /* in systems intended for surgical implant into the body, or other */
56: /* applications intended to support life, or for any other application in */
57: /* which the failure of the Motorola product could create a situation where */
58: /* personal injury or death may occur. Should Buyer purchase or use Motorola */
59: /* products for any such intended or unauthorized application, Buyer shall */
60: /* indemnify and hold Motorola and its officers, employees, subsidiaries, */
61: /* affiliates, and distributors harmless against all claims costs, damages, */
62: /* and expenses, and reasonable attorney fees arising out of, directly or */
63: /* indirectly, any claim of personal injury or death associated with such */
64: /* unintended or unauthorized use, even if such claim alleges that Motorola */
65: /* was negligent regarding the design or manufacture of the part. Motorola */
66: /* and the Motorola logo* are registered trademarks of Motorola Ltd. */
67: /*****************************************************************************/
68:
69: #include <hidef.h>
70: #include "const.h"
71: #include "ex5_extern.h"
72: #include "DP256Port.h"
73:
74: #define pviol 0x20
75: #define accerr 0x10
76: #define prog 0x20
77: #define ccif 0x40
78: #define cbeif 0x80
79: #define erase 0x40
80:
81: #define fcnfg (*((volatile unsigned char*)(0x0103)))
82: #define fstat (*((volatile unsigned char*)(0x0105)))
83: #define fcmd (*((volatile unsigned char*)(0x0106)))
84: #define eclkdiv (*((volatile unsigned char*)(0x0110)))
85: #define ecnfg (*((volatile unsigned char*)(0x0113)))
86: #define eprot (*((volatile unsigned char*)(0x0114)))
87: #define estat (*((volatile unsigned char*)(0x0115)))
88: #define ecmd (*((volatile unsigned char*)(0x0116)))
89:
90: #pragma CODE_SEG DEFAULT
91: /**********************************************
92: * PORTB bit test menu subroutine
93: * input : PORTB menu
94: * output : Corresponding sub-menu
95: ***********************************************/
96: void eeprom_test_menu(void)
97: {
Function: eeprom_test_menu
Source : D:\Code S12\Utility\S12DP256 CW31\S12 Ex5 EEPROM ICD CW31\sources\eeprom.c
Options : -Env"GENPATH=D:\Code S12\Utility\S12DP256 CW31\S12 Ex5 EEPROM ICD CW31;D:\Code S12\Utility\S12DP256 CW31\S12 Ex5 EEPROM ICD CW31\bin;D:\Code S12\Utility\S12DP256 CW31\S12 Ex5 EEPROM ICD CW31\cmd;D:\Code S12\Utility\S12DP256 CW31\S12 Ex5 EEPROM ICD CW31\prm;D:\Code S12\Utility\S12DP256 CW31\S12 Ex5 EEPROM ICD CW31\sources;D:\Metrowerks\CodeWarrior CW12_V3.0\lib\HC12c\LIB;D:\Metrowerks\CodeWarrior CW12_V3.0\lib\HC12c\SRC;D:\Metrowerks\CodeWarrior CW12_V3.0\lib\HC12c\INCLUDE" -Env"LIBPATH=D:\Metrowerks\CodeWarrior CW12_V3.0\lib\HC12c\INCLUDE" -Env"OBJPATH=D:\Code S12\Utility\S12DP256 CW31\S12 Ex5 EEPROM ICD CW31\bin" -Env"TEXTPATH=D:\Code S12\Utility\S12DP256 CW31\S12 Ex5 EEPROM ICD CW31\bin" -Lasm=%n.lst -ObjN="D:\Code S12\Utility\S12DP256 CW31\S12 Ex5 EEPROM ICD CW31\S12_Ex5_EEPROM_ICD_CW31_Data\Flash_Application\ObjectCode\eeprom.c.o" -Ol0
0000 1b9d LEAS -3,SP
98: byte cdata,loop=ENABLE;
0002 c601 LDAB #1
0004 6b81 STAB 1,SP
99:
100: while(loop==ENABLE)
101: {
102:
103: printf0("\n\t\tEEPROM Test Menu\n\r");
0006 cc0000 LDD #"\012\011\011EEPROM Test Menu\012\015"
0009 160000 JSR printf0
104: printf0("\t0. ROOT Test Menu\n\r");
000c cc0000 LDD #"\0110. ROOT Test Menu\012\015"
000f 160000 JSR printf0
105: printf0("\t1. EEPROM Program\n\r");
0012 cc0000 LDD #"\0111. EEPROM Program\012\015"
0015 160000 JSR printf0
106: printf0("\t2. EEPROM Erase\n\r");
0018 cc0000 LDD #"\0112. EEPROM Erase\012\015"
001b 160000 JSR printf0
107: printf0("\t9. Display DATA\n\r");
001e cc0000 LDD #"\0119. Display DATA\012\015"
0021 160000 JSR printf0
108:
109: do
110: {
111: cdata=menurx_char0(FLASH_PAGE);
0024 c610 LDAB #16
0026 160000 JSR menurx_char0
0029 6b82 STAB 2,SP
112: if(cdata==CR || cdata=='9')
002b c10d CMPB #13
002d 270c BEQ *+14 ;abs = 003b
002f c139 CMPB #57
0031 2708 BEQ *+10 ;abs = 003b
113: break;
114: }
115: while((cdata>'3') || (cdata<'0'));
0033 c133 CMPB #51
0035 22ed BHI *-17 ;abs = 0024
0037 c130 CMPB #48
0039 25e9 BCS *-21 ;abs = 0024
116: //get input from user
117:
118: switch(cdata)
003b c139 CMPB #57
003d 2226 BHI *+40 ;abs = 0065
003f c130 CMPB #48
0041 6b80 STAB 0,SP
0043 250d BCS *+15 ;abs = 0052
0045 c132 CMPB #50
0047 2209 BHI *+11 ;abs = 0052
0049 c030 SUBB #48
004b 87 CLRA
004c 160000 JSR _CASE_DIRECT_BYTE
004f 1b DC.B 27
0050 09 DC.B 9
0051 0e DC.B 14
0052 c139 CMPB #57
0054 270c BEQ *+14 ;abs = 0062
0056 200d BRA *+15 ;abs = 0065
119: {
120: case '0': loop=DISABLE;
121: break;
122: case '1': eeprom_program(); //flash_program();
0058 160000 JSR eeprom_program
123: break;
005b 2008 BRA *+10 ;abs = 0065
124: case '2': eeprom_erase();
005d 160000 JSR eeprom_erase
125: break;
0060 2003 BRA *+5 ;abs = 0065
126: case '9': data_display();
0062 160000 JSR data_display
0065 e681 LDAB 1,SP
0067 04119c DBEQ B,*-97 ;abs = 0006
127: break;
128: }
129: }
130: }
006a 1b83 LEAS 3,SP
006c 3d RTS
131:
132:
133: /*******************************************************************
134: * EEPROM program command subroutine
135: * Description : Copy from RAM area to EEPROM area
136: * : Input RAM,EEPROM start address and no. of word to be
137: * : programmed
138: * Example : Copy 4 words from RAM(0x1000) to EEPROM (0x600)
139: * input : eram_addi=0x1000, eeprom_addi=0x600, no_of word=0x4
140: * modify : eeprom content (0x600 to 0x608)= (0x1000 to 0x1008)
141: *********************************************************************/
142: void eeprom_program_cmd(int eram_addi, int eeprom_addi, int no_of_word)
143: {
Function: eeprom_program_cmd
Source : D:\Code S12\Utility\S12DP256 CW31\S12 Ex5 EEPROM ICD CW31\sources\eeprom.c
Options : -Env"GENPATH=D:\Code S12\Utility\S12DP256 CW31\S12 Ex5 EEPROM ICD CW31;D:\Code S12\Utility\S12DP256 CW31\S12 Ex5 EEPROM ICD CW31\bin;D:\Code S12\Utility\S12DP256 CW31\S12 Ex5 EEPROM ICD CW31\cmd;D:\Code S12\Utility\S12DP256 CW31\S12 Ex5 EEPROM ICD CW31\prm;D:\Code S12\Utility\S12DP256 CW31\S12 Ex5 EEPROM ICD CW31\sources;D:\Metrowerks\CodeWarrior CW12_V3.0\lib\HC12c\LIB;D:\Metrowerks\CodeWarrior CW12_V3.0\lib\HC12c\SRC;D:\Metrowerks\CodeWarrior CW12_V3.0\lib\HC12c\INCLUDE" -Env"LIBPATH=D:\Metrowerks\CodeWarrior CW12_V3.0\lib\HC12c\INCLUDE" -Env"OBJPATH=D:\Code S12\Utility\S12DP256 CW31\S12 Ex5 EEPROM ICD CW31\bin" -Env"TEXTPATH=D:\Code S12\Utility\S12DP256 CW31\S12 Ex5 EEPROM ICD CW31\bin" -Lasm=%n.lst -ObjN="D:\Code S12\Utility\S12DP256 CW31\S12 Ex5 EEPROM ICD CW31\S12_Ex5_EEPROM_ICD_CW31_Data\Flash_Application\ObjectCode\eeprom.c.o" -Ol0
0000 6ca8 STD 8,-SP
144: int *ram_add,*eeprom_add,count=0;
0002 c7 CLRB
0003 87 CLRA
0004 6c86 STD 6,SP
145:
146: ram_add=(int*)eram_addi;
0006 ee8c LDX 12,SP
0008 6e84 STX 4,SP
147: eeprom_add=(int*)eeprom_addi;
000a ee8a LDX 10,SP
000c 6e82 STX 2,SP
148: eclkdiv = 0x49;
000e c649 LDAB #73
0010 7b0110 STAB 272
149:
150: DisableInterrupts;
0013 1410 SEI
151:
152: estat=pviol+accerr; //movb #$30,$115 ; clear previous command error
0015 c630 LDAB #48
0017 7b0115 STAB 277
153: while(count!=no_of_word)
001a 203a BRA *+60 ;abs = 0056
154: {
155: *eeprom_add=*ram_add; //; get data and put it to EEPROM
001c ee84 LDX 4,SP
001e ec00 LDD 0,X
0020 ee82 LDX 2,SP
0022 6c00 STD 0,X
156: ecmd=prog; //; initiate PROGRAM COMMAND
0024 c620 LDAB #32
0026 7b0116 STAB 278
157: estat=cbeif; //; begin command
0029 8680 LDAA #128
002b 7a0115 STAA 277
158: if(((estat&pviol)==pviol)||((estat&accerr)==accerr))
002e 1e01152005 BRSET 277,#32,*+10 ;abs = 0038
0033 1f01151008 BRCLR 277,#16,*+13 ;abs = 0040
159: printf0("EEprom programming error\n\r"); //display eree_program_error
0038 cc0000 LDD #"EEprom programming error\012\015"
003b 160000 JSR printf0
003e 2005 BRA *+7 ;abs = 0045
160: else
161: while((estat&ccif)==0x00); // wait for command to complete
0040 1f011540fb BRCLR 277,#64,*+0 ;abs = 0040
162:
163: count++;
0045 ee86 LDX 6,SP
0047 08 INX
0048 6e86 STX 6,SP
164: eeprom_add++;
004a ee82 LDX 2,SP
004c 1a02 LEAX 2,X
004e 6e82 STX 2,SP
165: ram_add++;
0050 ee84 LDX 4,SP
0052 1a02 LEAX 2,X
0054 6e84 STX 4,SP
0056 ec86 LDD 6,SP
0058 ac80 CPD 0,SP
005a 26c0 BNE *-62 ;abs = 001c
166: }
167: EnableInterrupts;
005c 10ef CLI
168: }
005e 1b88 LEAS 8,SP
0060 3d RTS
169:
170:
171: /*******************************************************************
172: * EEPROM erase command subroutine
173: * Description : Erase EEPROM long word (4 bytes)
174: * : Input EEPROM start address and no. of word to be
175: * : erased
176: * Example : Erase 4 long words from EEPROM (0x600)
177: * input : eeprom_addi=0x600, no_of word=0x4
178: * modify : eeprom content (0x600-0x610)=0xff
179: *********************************************************************/
180: void eeprom_erase_cmd(int eeprom_addi, int no_of_long_word)
181: {
Function: eeprom_erase_cmd
Source : D:\Code S12\Utility\S12DP256 CW31\S12 Ex5 EEPROM ICD CW31\sources\eeprom.c
Options : -Env"GENPATH=D:\Code S12\Utility\S12DP256 CW31\S12 Ex5 EEPROM ICD CW31;D:\Code S12\Utility\S12DP256 CW31\S12 Ex5 EEPROM ICD CW31\bin;D:\Code S12\Utility\S12DP256 CW31\S12 Ex5 EEPROM ICD CW31\cmd;D:\Code S12\Utility\S12DP256 CW31\S12 Ex5 EEPROM ICD CW31\prm;D:\Code S12\Utility\S12DP256 CW31\S12 Ex5 EEPROM ICD CW31\sources;D:\Metrowerks\CodeWarrior CW12_V3.0\lib\HC12c\LIB;D:\Metrowerks\CodeWarrior CW12_V3.0\lib\HC12c\SRC;D:\Metrowerks\CodeWarrior CW12_V3.0\lib\HC12c\INCLUDE" -Env"LIBPATH=D:\Metrowerks\CodeWarrior CW12_V3.0\lib\HC12c\INCLUDE" -Env"OBJPATH=D:\Code S12\Utility\S12DP256 CW31\S12 Ex5 EEPROM ICD CW31\bin" -Env"TEXTPATH=D:\Code S12\Utility\S12DP256 CW31\S12 Ex5 EEPROM ICD CW31\bin" -Lasm=%n.lst -ObjN="D:\Code S12\Utility\S12DP256 CW31\S12 Ex5 EEPROM ICD CW31\S12_Ex5_EEPROM_ICD_CW31_Data\Flash_Application\ObjectCode\eeprom.c.o" -Ol0
0000 6caa STD 6,-SP
182: int *eeprom_add,count=0;
0002 c7 CLRB
0003 87 CLRA
0004 6c84 STD 4,SP
183:
184: eeprom_add=(int*)eeprom_addi;
0006 ee88 LDX 8,SP
0008 6e82 STX 2,SP
185: eclkdiv = 0x49;
000a c649 LDAB #73
000c 7b0110 STAB 272
186:
187: DisableInterrupts;
000f 1410 SEI
188:
189: estat=pviol+accerr; //movb #$30,$115 ; clear previous command error
0011 c630 LDAB #48
0013 7b0115 STAB 277
190: while(count!= no_of_long_word)
0016 204c BRA *+78 ;abs = 0064
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -