📄 ex4_portb.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: portb.c REVISION 0.2
13: *
14: * DESCRIPTION: Application code is placed here.
15: * This module handles all tasks related to the PortB
16: * Program to control the PORTB module to contorl bit hi/lo
17: * to turn on/off LED
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.20 Kenny Lam Initial version
35: * 0.1 2002.09.12 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 "const.h"
73: #include "ut_extern.h"
74: #include "ex4_extern.h"
75: #include "GlobalVar.h"
76: #include "DP256Port.h"
77:
78: /**********************************************
79: * PORTB bit test menu subroutine
80: * input : PORTB menu
81: * output : Corresponding sub-menu
82: ***********************************************/
83: void portb_test_menu(void)
84: {
Function: portb_test_menu
Source : D:\Profiles\r63492.FSL\My Documents\Training document\培训教材\HCS12\S12 Ex5 EEPROM ICD CW31\sources\ex4_portb.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\ex4_portb.c.o" -Ol0
0000 1b9d LEAS -3,SP
85: byte cdata,loop=ENABLE;
0002 c601 LDAB #1
0004 6b81 STAB 1,SP
86:
87: while(loop==ENABLE)
88: {
89: printf0("\n\t\tPORTB Test Menu\r");
0006 cc0000 LDD #"\012\011\011PORTB Test Menu\015"
0009 160000 JSR printf0
90: printf0("\n\t0. Root Test Menu\r");
000c cc0000 LDD #"\012\0110. Root Test Menu\015"
000f 160000 JSR printf0
91: printf0("\n\t1. Configures PORTB In/Out\r");
0012 cc0000 LDD #"\012\0111. Configures PORTB In/Out\015"
0015 160000 JSR printf0
92: printf0("\n\t2. Set PORTB LED on DP256\r");
0018 cc0000 LDD #"\012\0112. Set PORTB LED on DP256\015"
001b 160000 JSR printf0
93: printf0("\n\t9. Display DATA\r");
001e cc0000 LDD #"\012\0119. Display DATA\015"
0021 160000 JSR printf0
94: printf0("\n\r");
0024 cc0000 LDD #"\012\015"
0027 160000 JSR printf0
95: printf0("\nDPORTB PORTB Hour Min Sec\n\r");
002a cc0000 LDD #"\012DPORTB PORTB Hour Min Sec\012\015"
002d 160000 JSR printf0
96:
97: do
98: {
99: cdata=menurx_char0(PORTB_PAGE);
0030 c607 LDAB #7
0032 160000 JSR menurx_char0
0035 6b82 STAB 2,SP
100: if(cdata==CR || cdata=='9')
0037 c10d CMPB #13
0039 270c BEQ *+14 ;abs = 0047
003b c139 CMPB #57
003d 2708 BEQ *+10 ;abs = 0047
101: break;
102: }
103: while((cdata>'2') || (cdata<'0'));
003f c132 CMPB #50
0041 22ed BHI *-17 ;abs = 0030
0043 c130 CMPB #48
0045 25e9 BCS *-21 ;abs = 0030
104: //get input from user
105:
106:
107: switch(cdata)
0047 c139 CMPB #57
0049 2226 BHI *+40 ;abs = 0071
004b c130 CMPB #48
004d 6b80 STAB 0,SP
004f 250d BCS *+15 ;abs = 005e
0051 c132 CMPB #50
0053 2209 BHI *+11 ;abs = 005e
0055 c030 SUBB #48
0057 87 CLRA
0058 160000 JSR _CASE_DIRECT_BYTE
005b 1b DC.B 27
005c 09 DC.B 9
005d 0e DC.B 14
005e c139 CMPB #57
0060 270c BEQ *+14 ;abs = 006e
0062 200d BRA *+15 ;abs = 0071
108: {
109: case '0': loop=DISABLE;
110: break;
111: case '1': portb_config();
0064 160000 JSR portb_config
112: break;
0067 2008 BRA *+10 ;abs = 0071
113: case '2': portb_in_out();
0069 160000 JSR portb_in_out
114: break;
006c 2003 BRA *+5 ;abs = 0071
115: case '9': data_display();
006e 160000 JSR data_display
0071 e681 LDAB 1,SP
0073 041190 DBEQ B,*-109 ;abs = 0006
116: break;
117: }
118: }
119: }
0076 1b83 LEAS 3,SP
0078 3d RTS
120:
121: /**********************************************
122: * PORTB bit configuration subroutine
123: * modify : DDRB
124: ***********************************************/
125: void portb_config()
126: {
Function: portb_config
Source : D:\Profiles\r63492.FSL\My Documents\Training document\培训教材\HCS12\S12 Ex5 EEPROM ICD CW31\sources\ex4_portb.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\ex4_portb.c.o" -Ol0
0000 1b9a LEAS -6,SP
127: byte cdata=0;
0002 6985 CLR 5,SP
128: byte cmask=0xff;
129: int i,j;
130:
131: // cdata = DDRB;
132: /*=== Display DDRB as In/Out ===*/
133: for (i=0;i<8;i++) //display DDRB
0004 c7 CLRB
0005 87 CLRA
0006 6c80 STD 0,SP
134: {
135: printf0("\nPORTB bit \r");
0008 cc0000 LDD #"\012PORTB bit \015"
000b 160000 JSR portb_config:0x00d9
136: tx_char0(i+'0');
137: if (((DDRB>>i)&1)==0)
000e d603 LDAB 3
0010 a681 LDAA 1,SP
0012 160000 JSR _BSHRU
0015 c401 ANDB #1
0017 2605 BNE *+7 ;abs = 001e
138: printf0(" configures as input\r");
0019 cc0000 LDD #" configures as input\015"
001c 2003 BRA *+5 ;abs = 0021
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -