📄 ex3_utility.lst
字号:
ANSI-C/cC++ Compiler for HC12 V-5.0.24 Build 4047, Feb 17 2004
1: /******************************************************************************
2: *
3: * (c) copyright Freescale Semiconductor Hong Kong Ltd. 2004
4: * ALL RIGHTS RESERVED
5: *
6: *******************************************************************************
7: ** THIS CODE IS ONLY INTENDED AS AN EXAMPLE FOR DEMONSTRATING THE FREESCALE **
8: ** MICROCONTROLLERS. IT HAS ONLY BEEN GIVEN A MIMIMUM LEVEL OF TEST. IT IS **
9: ** PROVIDED 'AS SEEN' WITH NO GUARANTEES AND NO PROMISE OF SUPPORT. **
10: *******************************************************************************
11: *
12: * FILE: ex3_utility.c REVISION 0.2
13: *
14: * DESCRIPTION: Application code is placed here.
15: * This module handles all tasks related to the rs232 port
16: * Program to control the SCI0 module to send and receive ASCII
17: * to and from PC serial port RS232
18: *
19: * TARGET DEVICE: Hardware EVB912DP256 or equivalent
20: *
21: * COMPILER: Metrowerks VERSION: ADS v1.2 (initial version)
22: * VERSION: ADS v2.0 (Demo beta version)
23: * VERSION: ADS v3.1 (Demo version)
24: *
25: * NOTES
26: * -----
27: * All modules remain at their reset addresses.
28: *
29: *
30: * UPDATED HISTORY:
31: *
32: * REV YYYY.MM.DD AUTHOR DESCRIPTION OF CHANGE
33: * --- ---------- ------ ---------------------
34: * 0.0 2002.04.27 Kenny Lam Initial version
35: * 0.1 2002.12.18 Kenny Lam Demo beta version
36: * 0.2 2004.04.12 Kenny Lam Demo version
37: *
38: ******************************************************************************/
39: /* Freescale is not obligated to provide any support, upgrades or new */
40: /* releases of the Software. Freescale may make changes to the Software at */
41: /* any time, without any obligation to notify or provide updated versions of */
42: /* the Software to you. Freescale expressly disclaims any warranty for the */
43: /* Software. The Software is provided as is, without warranty of any kind, */
44: /* either express or implied, including, without limitation, the implied */
45: /* warranties of merchantability, fitness for a particular purpose, or */
46: /* non-infringement. You assume the entire risk arising out of the use or */
47: /* performance of the Software, or any systems you design using the software */
48: /* (if any). Nothing may be construed as a warranty or representation by */
49: /* Freescale that the Software or any derivative work developed with or */
50: /* incorporating the Software will be free from infringement of the */
51: /* intellectual property rights of third parties. In no event will Freescale */
52: /* be liable, whether in contract, tort, or otherwise, for any incidental, */
53: /* special, indirect, consequential or punitive damages, including, but not */
54: /* limited to, damages for any loss of use, loss of time, inconvenience, */
55: /* commercial loss, or lost profits, savings, or revenues to the full extent */
56: /* such may be disclaimed by law. The Software is not fault tolerant and is */
57: /* not designed, manufactured or intended by Freescale for incorporation */
58: /* into products intended for use or resale in on-line control equipment in */
59: /* hazardous, dangerous to life or potentially life-threatening environments */
60: /* requiring fail-safe performance, such as in the operation of nuclear */
61: /* facilities, aircraft navigation or communication systems, air traffic */
62: /* control, direct life support machines or weapons systems, in which the */
63: /* failure of products could lead directly to death, personal injury or */
64: /* severe physical or environmental damage (High Risk Activities). You */
65: /* specifically represent and warrant that you will not use the Software or */
66: /* any derivative work of the Software for High Risk Activities. */
67: /* Freescale and the Freescale logos are registered trademarks of Freescale */
68: /* Semiconductor Inc. */
69: /*****************************************************************************/
70:
71: #include <hidef.h>
72: #include <math.h>
73: #include "const.h"
74: #include "ut_extern.h"
75: #include "DP256Port.h"
76: #include "GlobalVar.h"
77:
78:
79: /*******************************************************************
80: * Init SCI port 0 as baud 9600 subroutine
81: * Description : Initial SCI as 9600 and enable tx and rx
82: * :
83: * Example : N/A
84: * Input : N/A
85: * Output : N/A
86: * Modify : N/A
87: * Return : N/A
88: ********************************************************************/
89: void init_SCI0 ()
90: {
Function: init_SCI0
Source : D:\Profiles\r63492.FSL\My Documents\Training document\培训教材\HCS12\S12 Ex5 EEPROM ICD CW31\sources\ex3_utility.c
Options : -DNON_BANK -Env"GENPATH=D:\Profiles\r63492.FSL\My Documents\Training document\培训教材\HCS12\S12 Ex5 EEPROM ICD CW31;D:\Profiles\r63492.FSL\My Documents\Training document\培训教材\HCS12\S12 Ex5 EEPROM ICD CW31\bin;D:\Profiles\r63492.FSL\My Documents\Training document\培训教材\HCS12\S12 Ex5 EEPROM ICD CW31\cmd;D:\Profiles\r63492.FSL\My Documents\Training document\培训教材\HCS12\S12 Ex5 EEPROM ICD CW31\prm;D:\Profiles\r63492.FSL\My Documents\Training document\培训教材\HCS12\S12 Ex5 EEPROM ICD CW31\sources;C:\Program Files\Metrowerks\CodeWarrior CW12_V3.1\lib\HC12c\LIB;C:\Program Files\Metrowerks\CodeWarrior CW12_V3.1\lib\HC12c\SRC;C:\Program Files\Metrowerks\CodeWarrior CW12_V3.1\lib\HC12c\INCLUDE" -Env"LIBPATH=C:\Program Files\Metrowerks\CodeWarrior CW12_V3.1\lib\HC12c\INCLUDE" -Env"OBJPATH=D:\Profiles\r63492.FSL\My Documents\Training document\培训教材\HCS12\S12 Ex5 EEPROM ICD CW31\bin" -Env"TEXTPATH=D:\Profiles\r63492.FSL\My Documents\Training document\培训教材\HCS12\S12 Ex5 EEPROM ICD CW31\bin" -Lasm=%n.lst -ObjN="D:\Profiles\r63492.FSL\My Documents\Training document\培训教材\HCS12\S12 Ex5 EEPROM ICD CW31\S12_Ex5_EEPROM_ICD_CW31_Data\FCS\ObjectCode\ex3_utility.c.o" -Ol0
91: SC0BDW=Eclock/16/9600; //9600 buad rate
0000 c634 LDAB #52
0002 87 CLRA
0003 5cc8 STD 200
92: SC0CR2=0xc; //enable tx,rx
0005 c60c LDAB #12
0007 5bcb STAB 203
93: }
0009 3d RTS
94:
95: /*******************************************************************
96: * Transmit char (ASCII) subroutine
97: * Description : Transmit ascii via RS232
98: * :
99: * Example : N/A
100: * Input : data
101: * Output : single ascii to screen
102: * Modify : N/A
103: * Return : N/A
104: ********************************************************************/
105: void tx_char0(char data)
106: {
Function: tx_char0
Source : D:\Profiles\r63492.FSL\My Documents\Training document\培训教材\HCS12\S12 Ex5 EEPROM ICD CW31\sources\ex3_utility.c
Options : -DNON_BANK -Env"GENPATH=D:\Profiles\r63492.FSL\My Documents\Training document\培训教材\HCS12\S12 Ex5 EEPROM ICD CW31;D:\Profiles\r63492.FSL\My Documents\Training document\培训教材\HCS12\S12 Ex5 EEPROM ICD CW31\bin;D:\Profiles\r63492.FSL\My Documents\Training document\培训教材\HCS12\S12 Ex5 EEPROM ICD CW31\cmd;D:\Profiles\r63492.FSL\My Documents\Training document\培训教材\HCS12\S12 Ex5 EEPROM ICD CW31\prm;D:\Profiles\r63492.FSL\My Documents\Training document\培训教材\HCS12\S12 Ex5 EEPROM ICD CW31\sources;C:\Program Files\Metrowerks\CodeWarrior CW12_V3.1\lib\HC12c\LIB;C:\Program Files\Metrowerks\CodeWarrior CW12_V3.1\lib\HC12c\SRC;C:\Program Files\Metrowerks\CodeWarrior CW12_V3.1\lib\HC12c\INCLUDE" -Env"LIBPATH=C:\Program Files\Metrowerks\CodeWarrior CW12_V3.1\lib\HC12c\INCLUDE" -Env"OBJPATH=D:\Profiles\r63492.FSL\My Documents\Training document\培训教材\HCS12\S12 Ex5 EEPROM ICD CW31\bin" -Env"TEXTPATH=D:\Profiles\r63492.FSL\My Documents\Training document\培训教材\HCS12\S12 Ex5 EEPROM ICD CW31\bin" -Lasm=%n.lst -ObjN="D:\Profiles\r63492.FSL\My Documents\Training document\培训教材\HCS12\S12 Ex5 EEPROM ICD CW31\S12_Ex5_EEPROM_ICD_CW31_Data\FCS\ObjectCode\ex3_utility.c.o" -Ol0
0000 37 PSHB
107: while ((SC0SR1&0x40)!=0x40);
0001 4fcc40fc BRCLR 204,#64,*+0 ;abs = 0001
108: SC0DRL = data;
0005 33 PULB
0006 5bcf STAB 207
109: }
0008 3d RTS
110:
111: /*******************************************************************
112: * printf0 subroutine
113: * Description : Transmit string via RS232
114: * :
115: * Example : N/A
116: * Input : *str
117: * Output : ascii to screen without lf and cr at the end
118: * Modify : N/A
119: * Return : N/A
120: ********************************************************************/
121: void printf0(char *str)
122: {
Function: printf0
Source : D:\Profiles\r63492.FSL\My Documents\Training document\培训教材\HCS12\S12 Ex5 EEPROM ICD CW31\sources\ex3_utility.c
Options : -DNON_BANK -Env"GENPATH=D:\Profiles\r63492.FSL\My Documents\Training document\培训教材\HCS12\S12 Ex5 EEPROM ICD CW31;D:\Profiles\r63492.FSL\My Documents\Training document\培训教材\HCS12\S12 Ex5 EEPROM ICD CW31\bin;D:\Profiles\r63492.FSL\My Documents\Training document\培训教材\HCS12\S12 Ex5 EEPROM ICD CW31\cmd;D:\Profiles\r63492.FSL\My Documents\Training document\培训教材\HCS12\S12 Ex5 EEPROM ICD CW31\prm;D:\Profiles\r63492.FSL\My Documents\Training document\培训教材\HCS12\S12 Ex5 EEPROM ICD CW31\sources;C:\Program Files\Metrowerks\CodeWarrior CW12_V3.1\lib\HC12c\LIB;C:\Program Files\Metrowerks\CodeWarrior CW12_V3.1\lib\HC12c\SRC;C:\Program Files\Metrowerks\CodeWarrior CW12_V3.1\lib\HC12c\INCLUDE" -Env"LIBPATH=C:\Program Files\Metrowerks\CodeWarrior CW12_V3.1\lib\HC12c\INCLUDE" -Env"OBJPATH=D:\Profiles\r63492.FSL\My Documents\Training document\培训教材\HCS12\S12 Ex5 EEPROM ICD CW31\bin" -Env"TEXTPATH=D:\Profiles\r63492.FSL\My Documents\Training document\培训教材\HCS12\S12 Ex5 EEPROM ICD CW31\bin" -Lasm=%n.lst -ObjN="D:\Profiles\r63492.FSL\My Documents\Training document\培训教材\HCS12\S12 Ex5 EEPROM ICD CW31\S12_Ex5_EEPROM_ICD_CW31_Data\FCS\ObjectCode\ex3_utility.c.o" -Ol0
0000 3b PSHD
123: while((*str != '\r'))
0001 2010 BRA *+18 ;abs = 0013
124: {
125: tx_char0(*str);
0003 0700 BSR tx_char0
126: if(*str++=='\n')
0005 ee80 LDX 0,SP
0007 e630 LDAB 1,X+
0009 6e80 STX 0,SP
000b c10a CMPB #10
000d 2604 BNE *+6 ;abs = 0013
127: tx_char0('\r');
000f c60d LDAB #13
0011 0700 BSR tx_char0
0013 ee80 LDX 0,SP
0015 e600 LDAB 0,X
0017 c10d CMPB #13
0019 26e8 BNE *-22 ;abs = 0003
128: }
129: }
001b 3a PULD
001c 3d RTS
130:
131: /**********************************************
132: * eat time subroutine
133: ***********************************************/
134: void delay1()
135: {
Function: delay1
Source : D:\Profiles\r63492.FSL\My Documents\Training document\培训教材\HCS12\S12 Ex5 EEPROM ICD CW31\sources\ex3_utility.c
Options : -DNON_BANK -Env"GENPATH=D:\Profiles\r63492.FSL\My Documents\Training document\培训教材\HCS12\S12 Ex5 EEPROM ICD CW31;D:\Profiles\r63492.FSL\My Documents\Training document\培训教材\HCS12\S12 Ex5 EEPROM ICD CW31\bin;D:\Profiles\r63492.FSL\My Documents\Training document\培训教材\HCS12\S12 Ex5 EEPROM ICD CW31\cmd;D:\Profiles\r63492.FSL\My Documents\Training document\培训教材\HCS12\S12 Ex5 EEPROM ICD CW31\prm;D:\Profiles\r63492.FSL\My Documents\Training document\培训教材\HCS12\S12 Ex5 EEPROM ICD CW31\sources;C:\Program Files\Metrowerks\CodeWarrior CW12_V3.1\lib\HC12c\LIB;C:\Program Files\Metrowerks\CodeWarrior CW12_V3.1\lib\HC12c\SRC;C:\Program Files\Metrowerks\CodeWarrior CW12_V3.1\lib\HC12c\INCLUDE" -Env"LIBPATH=C:\Program Files\Metrowerks\CodeWarrior CW12_V3.1\lib\HC12c\INCLUDE" -Env"OBJPATH=D:\Profiles\r63492.FSL\My Documents\Training document\培训教材\HCS12\S12 Ex5 EEPROM ICD CW31\bin" -Env"TEXTPATH=D:\Profiles\r63492.FSL\My Documents\Training document\培训教材\HCS12\S12 Ex5 EEPROM ICD CW31\bin" -Lasm=%n.lst -ObjN="D:\Profiles\r63492.FSL\My Documents\Training document\培训教材\HCS12\S12 Ex5 EEPROM ICD CW31\S12_Ex5_EEPROM_ICD_CW31_Data\FCS\ObjectCode\ex3_utility.c.o" -Ol0
136: unsigned int data;
137:
138: data=0xffff;
0000 ccffff LDD #65535
0003 3b PSHD
139: while((data--)!=0);
0004 ee80 LDX 0,SP
0006 191f LEAY -1,X
0008 6d80 STY 0,SP
000a 0475f7 TBNE X,*-6 ;abs = 0004
140: }
000d 3a PULD
000e 3d RTS
141:
142: /*******************************************************************
143: * int_div subroutine
144: * Description : Integer Divide Subroutine
145: * :
146: * Example : N/A
147: * Input : Intger to be divide, Divider
148: * Output : .quot, .mem
149: * Modify : N/A
150: * Return : N/A
151: ********************************************************************/
152: div_t int_div( int num, int denum)
153: {
Function: int_div
Source : D:\Profiles\r63492.FSL\My Documents\Training document\培训教材\HCS12\S12 Ex5 EEPROM ICD CW31\sources\ex3_utility.c
Options : -DNON_BANK -Env"GENPATH=D:\Profiles\r63492.FSL\My Documents\Training document\培训教材\HCS12\S12 Ex5 EEPROM ICD CW31;D:\Profiles\r63492.FSL\My Documents\Training document\培训教材\HCS12\S12 Ex5 EEPROM ICD CW31\bin;D:\Profiles\r63492.FSL\My Documents\Training document\培训教材\HCS12\S12 Ex5 EEPROM ICD CW31\cmd;D:\Profiles\r63492.FSL\My Documents\Training document\培训教材\HCS12\S12 Ex5 EEPROM ICD CW31\prm;D:\Profiles\r63492.FSL\My Documents\Training document\培训教材\HCS12\S12 Ex5 EEPROM ICD CW31\sources;C:\Program Files\Metrowerks\CodeWarrior CW12_V3.1\lib\HC12c\LIB;C:\Program Files\Metrowerks\CodeWarrior CW12_V3.1\lib\HC12c\SRC;C:\Program Files\Metrowerks\CodeWarrior CW12_V3.1\lib\HC12c\INCLUDE" -Env"LIBPATH=C:\Program Files\Metrowerks\CodeWarrior CW12_V3.1\lib\HC12c\INCLUDE" -Env"OBJPATH=D:\Profiles\r63492.FSL\My Documents\Training document\培训教材\HCS12\S12 Ex5 EEPROM ICD CW31\bin" -Env"TEXTPATH=D:\Profiles\r63492.FSL\My Documents\Training document\培训教材\HCS12\S12 Ex5 EEPROM ICD CW31\bin" -Lasm=%n.lst -ObjN="D:\Profiles\r63492.FSL\My Documents\Training document\培训教材\HCS12\S12 Ex5 EEPROM ICD CW31\S12_Ex5_EEPROM_ICD_CW31_Data\FCS\ObjectCode\ex3_utility.c.o" -Ol0
0000 3b PSHD
154: div_t static result;
155:
156: result.quot = 0;
0001 c7 CLRB
0002 87 CLRA
0003 7c0000 STD result
157: while(num >= denum)
0006 200b BRA *+13 ;abs = 0013
158: {
159: num -= denum;
0008 a380 SUBD 0,SP
000a 6c84 STD 4,SP
160: result.quot++;
000c fe0000 LDX result
000f 08 INX
0010 7e0000 STX result
0013 ec84 LDD 4,SP
0015 ac80 CPD 0,SP
0017 2cef BGE *-15 ;abs = 0008
161: }
162: result.rem = num;
0019 7c0000 STD result:2
163: return(result);
001c ee86 LDX 6,SP
001e fc0000 LDD result
0021 6c00 STD 0,X
0023 fc0000 LDD result:2
0026 6c02 STD 2,X
164: }
0028 31 PULY
0029 3d RTS
165:
166: /*******************************************************************
167: * Convert HEX to DEC and send out ASCII subroutine
168: * Description : Convert hex to dec and send out via RS232
169: * :
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -