📄 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:
76: /**********************************************
77: * Timer initilaisation subroutine
78: ***********************************************/
79: void init_timer()
80: {
Function: init_timer
Source : D:\Profiles\r63492.FSL\My Documents\Training document\培训教材\HCS12\S12 Ex5 EEPROM ICD CW31\sources\ex2_timer.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\ex2_timer.c.o" -Ol0
81: TIE = 0x80; //Enable ch7 timer
0000 c680 LDAB #128
0002 5b4c STAB 76
82:
83: TIOS = 0x80; //Select Channel 7 to act as output compare. 80
0004 5b40 STAB 64
84: TC7W = MS80; //updated 8msec with 8Mhz bus clk
0006 86fa LDAA #250
0008 c7 CLRB
0009 5c5e STD 94
85: TSCR1 = 0xb0; //Enable timer, Timer Module Stops While in Wait
000b c6b0 LDAB #176
000d 5b46 STAB 70
86: COPCTL =0;
000f 79003c CLR 60
87:
88: }
0012 3d RTS
89:
90: /**********************************************
91: * Timer interrupt service subroutine
92: * - Perform timer data update by 1 sec with
93: * bus clk = 8Mhz
94: ***********************************************/
95: #pragma CODE_SEG NON_BANKED
96: #pragma TRAP_PROC
97: void Timer7Overflow_ISR(void)
98: {
Function: Timer7Overflow_ISR
Source : D:\Profiles\r63492.FSL\My Documents\Training document\培训教材\HCS12\S12 Ex5 EEPROM ICD CW31\sources\ex2_timer.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\ex2_timer.c.o" -Ol0
99: TC7W += MS80; //updated 8msec with 8Mhz bus clk
0000 dc5e LDD 94
0002 c3fa00 ADDD #64000
0005 5c5e STD 94
100: Time8ms++;
0007 fc0000 LDD Time8ms:2
000a fe0000 LDX Time8ms
000d 160000 JSR _LINC
0010 7c0000 STD Time8ms:2
0013 7e0000 STX Time8ms
101: 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 2d30 BLT *+50 ;abs = 0053
102: {
103: PORTB ^=2; //toggle output port to drive LED 1 sec on/off
0023 d601 LDAB 1
0025 c802 EORB #2
0027 5b01 STAB 1
104: TimerCounter=0; //reset timer_counter
0029 790000 CLR TimerCounter
105: SecData++; //update second variable
002c 720000 INC SecData
106: if(SecData>=60)
002f f60000 LDAB SecData
0032 c13c CMPB #60
0034 2d06 BLT *+8 ;abs = 003c
107: {
108: SecData=0; //clear second variable
0036 790000 CLR SecData
109: MinData++; //update miniute variable
0039 720000 INC MinData
110: }
111: if(MinData>=60)
003c f60000 LDAB MinData
003f c13c CMPB #60
0041 2d06 BLT *+8 ;abs = 0049
112: {
113: MinData=0; //clear miniute variable
0043 790000 CLR MinData
114: HourData++; //update hour variable
0046 720000 INC HourData
115: }
116: if(HourData>=24)
0049 f60000 LDAB HourData
004c c118 CMPB #24
004e 2d03 BLT *+5 ;abs = 0053
117: HourData=0; //clear hour variable
0050 790000 CLR HourData
118: }
119:
120: }
0053 0b RTI
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -