📄 ex2_timer.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: ex2_timer.c REVISION 0.2
13: *
14: * DESCRIPTION: Application code is placed here.
15: * This module handles all tasks related to the internal timer
16: * Program to control the timer periodic interrupt
17: *
18: * TARGET DEVICE: Hardware EVB912DP256 or equivalent
19: *
20: * COMPILER: Metrowerks VERSION: ADS v1.2 (initial version)
21: * VERSION: ADS v2.0 (Demo beta version)
22: * VERSION: ADS v3.1 (Demo version)
23: *
24: * NOTES
25: * -----
26: * All modules remain at their reset addresses.
27: *
28: *
29: * UPDATED HISTORY:
30: *
31: * REV YYYY.MM.DD AUTHOR DESCRIPTION OF CHANGE
32: * --- ---------- ------ ---------------------
33: * 0.0 2002.04.20 Kenny Lam Initial version
34: * 0.1 2002.07.12 Kenny Lam Demo beta version
35: * 0.2 2004.04.12 Kenny Lam Demo version
36: *
37: ******************************************************************************/
38: /* Freescale is not obligated to provide any support, upgrades or new */
39: /* releases of the Software. Freescale may make changes to the Software at */
40: /* any time, without any obligation to notify or provide updated versions of */
41: /* the Software to you. Freescale expressly disclaims any warranty for the */
42: /* Software. The Software is provided as is, without warranty of any kind, */
43: /* either express or implied, including, without limitation, the implied */
44: /* warranties of merchantability, fitness for a particular purpose, or */
45: /* non-infringement. You assume the entire risk arising out of the use or */
46: /* performance of the Software, or any systems you design using the software */
47: /* (if any). Nothing may be construed as a warranty or representation by */
48: /* Freescale that the Software or any derivative work developed with or */
49: /* incorporating the Software will be free from infringement of the */
50: /* intellectual property rights of third parties. In no event will Freescale */
51: /* be liable, whether in contract, tort, or otherwise, for any incidental, */
52: /* special, indirect, consequential or punitive damages, including, but not */
53: /* limited to, damages for any loss of use, loss of time, inconvenience, */
54: /* commercial loss, or lost profits, savings, or revenues to the full extent */
55: /* such may be disclaimed by law. The Software is not fault tolerant and is */
56: /* not designed, manufactured or intended by Freescale for incorporation */
57: /* into products intended for use or resale in on-line control equipment in */
58: /* hazardous, dangerous to life or potentially life-threatening environments */
59: /* requiring fail-safe performance, such as in the operation of nuclear */
60: /* facilities, aircraft navigation or communication systems, air traffic */
61: /* control, direct life support machines or weapons systems, in which the */
62: /* failure of products could lead directly to death, personal injury or */
63: /* severe physical or environmental damage (High Risk Activities). You */
64: /* specifically represent and warrant that you will not use the Software or */
65: /* any derivative work of the Software for High Risk Activities. */
66: /* Freescale and the Freescale logos are registered trademarks of Freescale */
67: /* Semiconductor Inc. */
68: /*****************************************************************************/
69:
70: #include <hidef.h>
71: #include "const.h"
72: #include "DP256Port.h"
73: #include "GlobalVar.h"
74:
75: #ifdef BANKED
76: #pragma CODE_SEG CodeForcedToPPage33
77: #else
78: #pragma CODE_SEG DEFAULT
79: #endif
80:
81: /**********************************************
82: * Timer initilaisation subroutine
83: ***********************************************/
84: void init_timer()
85: {
Function: init_timer
Source : D:\Profiles\r63492.FSL\My Documents\Training document\培训教材\HCS12\S12 Ex2 Timer7 ICD CW31\sources\ex2_timer.c
Options : -DRAM -Env"GENPATH=D:\Profiles\r63492.FSL\My Documents\Training document\培训教材\HCS12\S12 Ex2 Timer7 ICD CW31;D:\Profiles\r63492.FSL\My Documents\Training document\培训教材\HCS12\S12 Ex2 Timer7 ICD CW31\bin;D:\Profiles\r63492.FSL\My Documents\Training document\培训教材\HCS12\S12 Ex2 Timer7 ICD CW31\cmd;D:\Profiles\r63492.FSL\My Documents\Training document\培训教材\HCS12\S12 Ex2 Timer7 ICD CW31\prm;D:\Profiles\r63492.FSL\My Documents\Training document\培训教材\HCS12\S12 Ex2 Timer7 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 Ex2 Timer7 ICD CW31\bin" -Env"TEXTPATH=D:\Profiles\r63492.FSL\My Documents\Training document\培训教材\HCS12\S12 Ex2 Timer7 ICD CW31\bin" -Lasm=%n.lst -ObjN="D:\Profiles\r63492.FSL\My Documents\Training document\培训教材\HCS12\S12 Ex2 Timer7 ICD CW31\S12_Ex2_Timer7_ICD_CW31_Data\Ram_Application\ObjectCode\ex2_timer.c.o" -Ol0
86: TIE = 0x80; //Enable ch7 timer
0000 c680 LDAB #128
0002 5b4c STAB 76
87:
88: TIOS = 0x80; //Select Channel 7 to act as output compare. 80
0004 5b40 STAB 64
89: TC7W = MS80; //updated 8msec with 8Mhz bus clk
0006 86fa LDAA #250
0008 c7 CLRB
0009 5c5e STD 94
90: TSCR1 = 0xb0; //Enable timer, Timer Module Stops While in Wait
000b c6b0 LDAB #176
000d 5b46 STAB 70
91: COPCTL =0;
000f 79003c CLR 60
92:
93: }
0012 3d RTS
94:
95: /**********************************************
96: * Timer interrupt service subroutine
97: * - Perform timer data update by 1 sec with
98: * bus clk = 8Mhz
99: ***********************************************/
100: #pragma CODE_SEG NON_BANKED
101: #pragma TRAP_PROC
102: void Timer7Overflow_ISR(void)
103: {
Function: Timer7Overflow_ISR
Source : D:\Profiles\r63492.FSL\My Documents\Training document\培训教材\HCS12\S12 Ex2 Timer7 ICD CW31\sources\ex2_timer.c
Options : -DRAM -Env"GENPATH=D:\Profiles\r63492.FSL\My Documents\Training document\培训教材\HCS12\S12 Ex2 Timer7 ICD CW31;D:\Profiles\r63492.FSL\My Documents\Training document\培训教材\HCS12\S12 Ex2 Timer7 ICD CW31\bin;D:\Profiles\r63492.FSL\My Documents\Training document\培训教材\HCS12\S12 Ex2 Timer7 ICD CW31\cmd;D:\Profiles\r63492.FSL\My Documents\Training document\培训教材\HCS12\S12 Ex2 Timer7 ICD CW31\prm;D:\Profiles\r63492.FSL\My Documents\Training document\培训教材\HCS12\S12 Ex2 Timer7 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 Ex2 Timer7 ICD CW31\bin" -Env"TEXTPATH=D:\Profiles\r63492.FSL\My Documents\Training document\培训教材\HCS12\S12 Ex2 Timer7 ICD CW31\bin" -Lasm=%n.lst -ObjN="D:\Profiles\r63492.FSL\My Documents\Training document\培训教材\HCS12\S12 Ex2 Timer7 ICD CW31\S12_Ex2_Timer7_ICD_CW31_Data\Ram_Application\ObjectCode\ex2_timer.c.o" -Ol0
104: TC7W += MS80; //updated 8msec with 8Mhz bus clk
0000 dc5e LDD 94
0002 c3fa00 ADDD #64000
0005 5c5e STD 94
105: Time8ms++;
0007 fc0000 LDD Time8ms:2
000a fe0000 LDX Time8ms
000d 160000 JSR _LINC
0010 7c0000 STD Time8ms:2
0013 7e0000 STX Time8ms
106: if (TimerCounter++ >=125)
0016 f60000 LDAB TimerCounter
0019 37 PSHB
001a 52 INCB
001b 7b0000 STAB TimerCounter
001e 33 PULB
001f c17d CMPB #125
0021 2d32 BLT *+52 ;abs = 0055
107: {
108: //PORTB ^=2; //toggle output port to drive LED 1 sec on/off
109: PORTS ^=2;
0023 f60248 LDAB 584
0026 c802 EORB #2
0028 7b0248 STAB 584
110: TimerCounter=0; //reset timer_counter
002b 790000 CLR TimerCounter
111: SecData++; //update second variable
002e 720000 INC SecData
112: if(SecData>=60)
0031 f60000 LDAB SecData
0034 c13c CMPB #60
0036 2d06 BLT *+8 ;abs = 003e
113: {
114: SecData=0; //clear second variable
0038 790000 CLR SecData
115: MinData++; //update miniute variable
003b 720000 INC MinData
116: }
117: if(MinData>=60)
003e f60000 LDAB MinData
0041 c13c CMPB #60
0043 2d06 BLT *+8 ;abs = 004b
118: {
119: MinData=0; //clear miniute variable
0045 790000 CLR MinData
120: HourData++; //update hour variable
0048 720000 INC HourData
121: }
122: if(HourData>=24)
004b f60000 LDAB HourData
004e c118 CMPB #24
0050 2d03 BLT *+5 ;abs = 0055
123: HourData=0; //clear hour variable
0052 790000 CLR HourData
124: }
125:
126: }
0055 0b RTI
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -