📄 portb.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: portb.c REVISION R1B
4: * PURPOSE: This module handles all tasks related to the PortB
5: *
6: *******************************************************************************
7: *******************************************************************************
8: ** THIS CODE IS ONLY INTENDED AS AN EXAMPLE FOR THE METROWERKS COMPILER AND **
9: ** THE HCS 12 EVB AND HAS ONLY BEEN GIVEN A MIMIMUM LEVEL OF TEST. **
10: ** IT IS PROVIDED 'AS SEEN' WITH NO GUARANTEES AND NO PROMISE OF SUPPORT. **
11: *******************************************************************************
12: *******************************************************************************
13: *
14: * DOCUMENTATION SOURCE: Motorola TSPG 8/16 MCU bit Division (HKG)
15: *
16: * TARGET DEVICE: Hardware EVB912DP256 or equivalent
17: *
18: * INCLUDE FILES: <hidef.h>
19: * <math.h>
20: * "com.h"
21: * "DP256Port.h"
22: * "GlobalVar.h"
23: *
24: * FUNCTIONS : portb_test_menu
25: * portb_config
26: * portb_in_out
27: * portb_info
28: * portb_info_detail
29: *
30: * COMPILER: Metrowerks VERSION: ADS v1.2
31: *
32: * DESCRIPTION: Program to control the PORTB module to contorl bit hi/lo
33: * to turn on/off LED
34: *
35: * INPUTS
36: * ------
37: * All commands are inovked by PC Hyperterminal via SCI0
38: * The PortB to drive the EVB912DP256 LED on/off
39: *
40: * NOTES
41: * -----
42: * All modules remain at their reset addresses.
43: *
44: *
45: * UPDATE HISTORY
46: * REV AUTHOR DATE DESCRIPTION OF CHANGE
47: * --- ------ --------- ---------------------
48: * R1A r29566 02/04/20 Initial version
49: * R1B r29566 02/09/12 Demo version
50: *
51: ******************************************************************************/
52: /*===========================================================================*/
53: /* Motorola reserves the right to make changes without further notice to any */
54: /* product herein to improve reliability, function, or design. Motorola does */
55: /* not assume any liability arising out of the application or use of any */
56: /* product, circuit, or software described herein; neither does it convey */
57: /* any license under its patent rights nor the rights of others. Motorola */
58: /* products are not designed, intended, or authorized for use as components */
59: /* in systems intended for surgical implant into the body, or other */
60: /* applications intended to support life, or for any other application in */
61: /* which the failure of the Motorola product could create a situation where */
62: /* personal injury or death may occur. Should Buyer purchase or use Motorola */
63: /* products for any such intended or unauthorized application, Buyer shall */
64: /* indemnify and hold Motorola and its officers, employees, subsidiaries, */
65: /* affiliates, and distributors harmless against all claims costs, damages, */
66: /* and expenses, and reasonable attorney fees arising out of, directly or */
67: /* indirectly, any claim of personal injury or death associated with such */
68: /* unintended or unauthorized use, even if such claim alleges that Motorola */
69: /* was negligent regarding the design or manufacture of the part. Motorola */
70: /* and the Motorola logo* are registered trademarks of Motorola Ltd. */
71: /*****************************************************************************/
72:
73: #include <hidef.h>
74: #include "const.h"
75: #include "ex4_extern.h"
76: #include "GlobalVar.h"
77: #include "DP256Port.h"
78:
79: #pragma CODE_SEG DEFAULT
80: /**********************************************
81: * PORTB bit test menu subroutine
82: * input : PORTB menu
83: * output : Corresponding sub-menu
84: ***********************************************/
85: void portb_test_menu(void)
86: {
Function: portb_test_menu
Source : D:\Code S12\Utility\S12DP256 CW31\S12 Ex5 EEPROM ICD CW31\sources\portb.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\portb.c.o" -Ol0
0000 1b9d LEAS -3,SP
87: byte cdata,loop=ENABLE;
0002 c601 LDAB #1
0004 6b81 STAB 1,SP
88:
89: while(loop==ENABLE)
90: {
91: printf0("\n\t\tPORTB Test Menu\r");
0006 cc0000 LDD #"\012\011\011PORTB Test Menu\015"
0009 160000 JSR printf0
92: printf0("\n\t0. Root Test Menu\r");
000c cc0000 LDD #"\012\0110. Root Test Menu\015"
000f 160000 JSR printf0
93: printf0("\n\t1. Configures PORTB In/Out\r");
0012 cc0000 LDD #"\012\0111. Configures PORTB In/Out\015"
0015 160000 JSR printf0
94: printf0("\n\t2. Set PORTB LED on DP256\r");
0018 cc0000 LDD #"\012\0112. Set PORTB LED on DP256\015"
001b 160000 JSR printf0
95: printf0("\n\t9. Display DATA\r");
001e cc0000 LDD #"\012\0119. Display DATA\015"
0021 160000 JSR printf0
96: printf0("\n\r");
0024 cc0000 LDD #"\012\015"
0027 160000 JSR printf0
97: printf0("\nDPORTB PORTB Hour Min Sec\n\r");
002a cc0000 LDD #"\012DPORTB PORTB Hour Min Sec\012\015"
002d 160000 JSR printf0
98:
99: do
100: {
101: cdata=menurx_char0(PORTB_PAGE);
0030 c607 LDAB #7
0032 160000 JSR menurx_char0
0035 6b82 STAB 2,SP
102: 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
103: break;
104: }
105: 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
106: //get input from user
107:
108:
109: 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
110: {
111: case '0': loop=DISABLE;
112: break;
113: case '1': portb_config();
0064 160000 JSR portb_config
114: break;
0067 2008 BRA *+10 ;abs = 0071
115: case '2': portb_in_out();
0069 160000 JSR portb_in_out
116: break;
006c 2003 BRA *+5 ;abs = 0071
117: case '9': data_display();
006e 160000 JSR data_display
0071 e681 LDAB 1,SP
0073 041190 DBEQ B,*-109 ;abs = 0006
118: break;
119: }
120: }
121: }
0076 1b83 LEAS 3,SP
0078 3d RTS
122:
123: /**********************************************
124: * PORTB bit configuration subroutine
125: * modify : DDRB
126: ***********************************************/
127: void portb_config()
128: {
Function: portb_config
Source : D:\Code S12\Utility\S12DP256 CW31\S12 Ex5 EEPROM ICD CW31\sources\portb.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\portb.c.o" -Ol0
0000 1b9a LEAS -6,SP
129: byte cdata=0;
0002 6985 CLR 5,SP
130: byte cmask=0xff;
131: int i,j;
132:
133: // cdata = DDRB;
134: /*=== Display DDRB as In/Out ===*/
135: for (i=0;i<8;i++) //display DDRB
0004 c7 CLRB
0005 87 CLRA
0006 6c80 STD 0,SP
136: {
137: printf0("\nPORTB bit \r");
0008 cc0000 LDD #"\012PORTB bit \015"
000b 160000 JSR portb_config:0x00d9
138: tx_char0(i+'0');
139: 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
140: printf0(" configures as input\r");
0019 cc0000 LDD #" configures as input\015"
001c 2003 BRA *+5 ;abs = 0021
141: else
142: // tx_char0(i+'0');
143: printf0(" configures as output\r");
001e cc0000 LDD #" configures as output\015"
0021 160000 JSR printf0
0024 160000 JSR portb_config:0x00e3
0027 2ddf BLT *-31 ;abs = 0008
144: }
145:
146: /*=== Display option for user select ===*/
147: printf0("\n 0. Quit\r");
0029 cc0000 LDD #"\012\0110. Quit\015"
002c 160000 JSR printf0
148: printf0("\n 1. Configures PORTB In/Out\n\r");
002f cc0000 LDD #"\012\0111. Configures PORTB In/Out\012\015"
0032 160000 JSR printf0
149:
150: do //get input from user
151: {
152: if(cdata!=0) // do once
0035 e685 LDAB 5,SP
0037 1826008d LBNE *+145 ;abs = 00c8
153: break;
154: cdata=rx_char0();
003b 160000 JSR rx_char0
003e 6b85 STAB 5,SP
155: if (cdata=='1') //get input from user
0040 c131 CMPB #49
0042 2678 BNE *+122 ;abs = 00bc
156: {
157: for (i=0;i<8;i++) //display bit by bit
0044 c7 CLRB
0045 87 CLRA
0046 6c80 STD 0,SP
158: {
159: printf0("\nPORTB bit \r");
0048 cc0000 LDD #"\012PORTB bit \015"
004b 160000 JSR portb_config:0x00d9
160: tx_char0(i+'0');
161: printf0(" (0 = In, 1 = Out, ESC = Quit)\r");
004e cc0000 LDD #" (0 = In, 1 = Out, ESC = Quit)\015"
0051 160000 JSR printf0
162: do
163: {
164: cdata=rx_char0();
0054 160000 JSR rx_char0
0057 6b85 STAB 5,SP
165: if(cdata==ESC)
0059 c11b CMPB #27
005b 2607 BNE *+9 ;abs = 0064
166: {
167: i=8;
005d c608 LDAB #8
005f 87 CLRA
0060 6c80 STD 0,SP
168: break;
0062 2008 BRA *+10 ;abs = 006c
169: } //force to finish the for loop.
170: }
171: while((cdata>'1') || (cdata<'0'));
0064 c131 CMPB #49
0066 22ec BHI *-18 ;abs = 0054
0068 c130 CMPB #48
006a 25e8 BCS *-22 ;abs = 0054
172:
173: if(cdata=='0')
006c e685 LDAB 5,SP
006e c130 CMPB #48
0070 2620 BNE *+34 ;abs = 0092
174: {
175: cmask=0xfe;
0072 c6fe LDAB #254
0074 6b82 STAB 2,SP
176: for(j=0;j<i;j++)
0076 c7 CLRB
0077 87 CLRA
0078 6c83 STD 3,SP
007a 200a BRA *+12 ;abs = 0086
177: cmask= (cmask << 1) | ((cmask & 0x80)? 0x1 : 0x00);
007c 0e828002 BRSET 2,SP,#128,*+6 ;abs = 0082
0080 c7 CLRB
0081 8f SKIP2
0082 c601 LDAB #1
0084 0745 BSR *+71 ;abs = 00cb
0086 ec83 LDD 3,SP
0088 ac80 CPD 0,SP
008a 2df0 BLT *-14 ;abs = 007c
178: DDRB = DDRB & cmask;
008c d603 LDAB 3
008e e482 ANDB 2,SP
0090 5b03 STAB 3
179: }
180: if(cdata=='1')
0092 e685 LDAB 5,SP
0094 c131 CMPB #49
0096 2620 BNE *+34 ;abs = 00b8
181: {
182: cmask=0x1;
0098 c601 LDAB #1
009a 6b82 STAB 2,SP
183: for(j=0;j<i;j++)
009c c7 CLRB
009d 87 CLRA
009e 6c83 STD 3,SP
00a0 200a BRA *+12 ;abs = 00ac
184: cmask= (cmask << 1) | ((cmask & 0x80)? 0x1 : 0x00);
00a2 0e828002 BRSET 2,SP,#128,*+6 ;abs = 00a8
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -