?? timer.lst
字號(hào):
ARM COMPILER V2.53, timer 27/07/06 14:35:28 PAGE 1
ARM COMPILER V2.53, COMPILATION OF MODULE timer
OBJECT MODULE PLACED IN .\Obj\timer.obj
COMPILER INVOKED BY: g:\Keil\ARM\BIN\CA.exe ..\Common\src\timer.c THUMB INCDIR(..\Common\inc) DEBUG PRINT(.\LST\TIMER.LS
-T) TABS(4) OBJECT(.\Obj\timer.obj)
stmt level source
1 /*****************************************************************************
2 * timer.c: Timer C file for Philips LPC214x Family Microprocessors
3 *
4 * Copyright(C) 2006, Philips Semiconductor
5 * All rights reserved.
6 *
7 * History
8 * 2005.10.01 ver 1.00 Prelimnary version, first Release
9 *
10 ******************************************************************************/
11 #include "LPC214x.h" /* LPC21XX Peripheral Registers */
12 #include "type.h"
13 #include "irq.h"
14 #include "timer.h"
15
16 DWORD timer_counter = 0;
17
18 /******************************************************************************
19 ** Function name: Timer0Handler
20 **
21 ** Descriptions: Timer/Counter 0 interrupt handler
22 ** executes each 10ms @ 60 MHz CPU Clock
23 **
24 ** parameters: None
25 ** Returned value: None
26 **
27 ******************************************************************************/
28 void Timer0Handler (void) __irq
29 {
30 1 T0IR = 1; /* clear interrupt flag */
31 1 IENABLE; /* handles nested interrupt */
32 1
33 1 timer_counter++;
34 1
35 1 IDISABLE;
36 1 VICVectAddr = 0; /* Acknowledge Interrupt */
37 1 }
38
39 /******************************************************************************
40 ** Function name: enable_timer
41 **
42 ** Descriptions: Enable timer
43 **
44 ** parameters: timer number: 0 or 1
45 ** Returned value: None
46 **
47 ******************************************************************************/
48 void enable_timer( BYTE timer_num )
49 {
50 1 if ( timer_num == 0 )
51 1 {
52 2 T0TCR = 1;
53 2 }
54 1 else
55 1 {
56 2 T1TCR = 1;
57 2 }
58 1 return;
ARM COMPILER V2.53, timer 27/07/06 14:35:28 PAGE 2
59 1 }
60
61 /******************************************************************************
62 ** Function name: disable_timer
63 **
64 ** Descriptions: Disable timer
65 **
66 ** parameters: timer number: 0 or 1
67 ** Returned value: None
68 **
69 ******************************************************************************/
70 void disable_timer( BYTE timer_num )
71 {
72 1 if ( timer_num == 0 )
73 1 {
74 2 T0TCR = 0;
75 2 }
76 1 else
77 1 {
78 2 T1TCR = 0;
79 2 }
80 1 return;
81 1 }
82
83 /******************************************************************************
84 ** Function name: reset_timer
85 **
86 ** Descriptions: Reset timer
87 **
88 ** parameters: timer number: 0 or 1
89 ** Returned value: None
90 **
91 ******************************************************************************/
92 void reset_timer( BYTE timer_num )
93 {
94 1 DWORD regVal;
95 1
96 1 if ( timer_num == 0 )
97 1 {
98 2 regVal = T0TCR;
99 2 regVal |= 0x02;
100 2 T0TCR = regVal;
101 2 }
102 1 else
103 1 {
104 2 regVal = T1TCR;
105 2 regVal |= 0x02;
106 2 T1TCR = regVal;
107 2 }
108 1 return;
109 1 }
110
111 /******************************************************************************
112 ** Function name: init_timer
113 **
114 ** Descriptions: Initialize timer, set timer interval, reset timer,
115 ** install timer interrupt handler
116 **
117 ** parameters: None
118 ** Returned value: true or false, if the interrupt handler can't be
119 ** installed, return false.
120 **
121 ******************************************************************************/
122 DWORD init_timer (void)
123 {
124 1 timer_counter = 0;
ARM COMPILER V2.53, timer 27/07/06 14:35:28 PAGE 3
125 1 T0MR0 = INTERVAL_10MS; /* 10mSec = 150.000-1 counts */
126 1 T0MCR = 3; /* Interrupt and Reset on MR0 */
127 1 if ( install_irq( TIMER0_INT, (void *)Timer0Handler ) == FALSE )
128 1 {
129 2 return (FALSE);
130 2 }
131 1 else
132 1 {
133 2 return (TRUE);
134 2 }
135 1 }
136
ARM COMPILER V2.53, timer 27/07/06 14:35:28 PAGE 4
ASSEMBLY LISTING OF GENERATED OBJECT CODE
*** EXTERNALS:
EXTERN CODE16 (install_irq?T)
*** PUBLICS:
PUBLIC init_timer?T
PUBLIC enable_timer?T
PUBLIC disable_timer?T
PUBLIC reset_timer?T
PUBLIC Timer0Handler?A
PUBLIC timer_counter
*** DATA SEGMENT '?DT0?timer':
00000000 timer_counter:
00000000 BEGIN_INIT
00000000 00000000 DD 0x0
00000004 END_INIT
*** CODE SEGMENT '?PR?Timer0Handler?A?timer':
28: void Timer0Handler (void) __irq
00000000 E92D4003 STMDB R13!,{R0-R1,LR}
30: T0IR = 1; /* clear interrupt flag */
00000004 E3A01001 MOV R1,#0x1
00000008 E5100000 LDR R0,=0xE0004000
0000000C E5801000 STR R1,[R0,#0x0]
31: IENABLE; /* handles nested interrupt */
00000010 E14FE000 MRS R14,SPSR
00000014 E92D4000 STMFD R13!,{LR}
00000018 E321F01F MSR CPSR_c,#0x1F
0000001C E92D4000 STMFD R13!,{LR}
33: timer_counter++;
00000020 E5100000 LDR R0,=timer_counter ; timer_counter
00000024 E5901000 LDR R1,[R0,#0x0] ; timer_counter
00000028 E2811001 ADD R1,R1,#0x0001
0000002C E5801000 STR R1,[R0,#0x0] ; timer_counter
35: IDISABLE;
00000030 E8BD4000 LDMFD R13!,{LR}
00000034 E321F092 MSR CPSR_c,#0x92
00000038 E8BD4000 LDMFD R13!,{LR}
0000003C E16FF00E MSR SPSR_cxsf,R14
36: VICVectAddr = 0; /* Acknowledge Interrupt */
00000040 E3A01000 MOV R1,#0x0
00000044 E5100000 LDR R0,=0xFFFFF030
00000048 E5801000 STR R1,[R0,#0x0]
37: }
0000004C E8BD4003 LDMIA R13!,{R0-R1,LR}
00000050 E25EF004 SUBS R15,R14,#0x0004
00000054 ENDP ; 'Timer0Handler?A'
*** CODE SEGMENT '?PR?enable_timer?T?timer':
48: void enable_timer( BYTE timer_num )
00000000 1C01 MOV R1,R0 ; timer_num
00000002 ---- Variable 'timer_num' assigned to Register 'R1' ----
50: if ( timer_num == 0 )
00000002 1C08 MOV R0,R1 ; timer_num
00000004 0600 LSL R0,R0,#0x18 ; timer_num
00000006 0E00 LSR R0,R0,#0x18
00000008 2800 CMP R0,#0x0
0000000A D103 BNE L_1 ; T=0x00000014
52: T0TCR = 1;
0000000C 2101 MOV R1,#0x1
0000000E 4800 LDR R0,=0xE0004004
00000010 6001 STR R1,[R0,#0x0]
53: }
00000012 E002 B L_2 ; T=0x0000001A
ARM COMPILER V2.53, timer 27/07/06 14:35:28 PAGE 5
00000014 L_1:
56: T1TCR = 1;
00000014 2101 MOV R1,#0x1
00000016 4800 LDR R0,=0xE0008004
00000018 6001 STR R1,[R0,#0x0]
57: }
0000001A L_2:
59: }
0000001A 4770 BX R14
0000001C ENDP ; 'enable_timer?T'
*** CODE SEGMENT '?PR?disable_timer?T?timer':
70: void disable_timer( BYTE timer_num )
00000000 1C01 MOV R1,R0 ; timer_num
00000002 ---- Variable 'timer_num' assigned to Register 'R1' ----
72: if ( timer_num == 0 )
00000002 1C08 MOV R0,R1 ; timer_num
00000004 0600 LSL R0,R0,#0x18 ; timer_num
00000006 0E00 LSR R0,R0,#0x18
00000008 2800 CMP R0,#0x0
0000000A D103 BNE L_4 ; T=0x00000014
74: T0TCR = 0;
0000000C 2100 MOV R1,#0x0
0000000E 4800 LDR R0,=0xE0004004
00000010 6001 STR R1,[R0,#0x0]
75: }
00000012 E002 B L_5 ; T=0x0000001A
00000014 L_4:
78: T1TCR = 0;
00000014 2100 MOV R1,#0x0
00000016 4800 LDR R0,=0xE0008004
00000018 6001 STR R1,[R0,#0x0]
79: }
0000001A L_5:
81: }
0000001A 4770 BX R14
0000001C ENDP ; 'disable_timer?T'
*** CODE SEGMENT '?PR?reset_timer?T?timer':
92: void reset_timer( BYTE timer_num )
00000000 1C02 MOV R2,R0 ; timer_num
00000002 ---- Variable 'timer_num' assigned to Register 'R2' ----
00000002 ---- Variable 'regVal' assigned to Register 'R1' ----
93: {
00000002 ; SCOPE-START
96: if ( timer_num == 0 )
00000002 1C10 MOV R0,R2 ; timer_num
00000004 0600 LSL R0,R0,#0x18 ; timer_num
00000006 0E00 LSR R0,R0,#0x18
00000008 2800 CMP R0,#0x0
0000000A D107 BNE L_7 ; T=0x0000001C
98: regVal = T0TCR;
0000000C 4800 LDR R0,=0xE0004004
0000000E 6801 LDR R1,[R0,#0x0]
99: regVal |= 0x02;
00000010 2002 MOV R0,#0x2
00000012 4301 ORR R1,R0
100: T0TCR = regVal;
00000014 1C0A MOV R2,R1 ; regVal
00000016 4800 LDR R0,=0xE0004004
00000018 6002 STR R2,[R0,#0x0]
101: }
0000001A E006 B L_8 ; T=0x0000002A
0000001C L_7:
104: regVal = T1TCR;
0000001C 4800 LDR R0,=0xE0008004
0000001E 6801 LDR R1,[R0,#0x0]
105: regVal |= 0x02;
ARM COMPILER V2.53, timer 27/07/06 14:35:28 PAGE 6
00000020 2002 MOV R0,#0x2
00000022 4301 ORR R1,R0
106: T1TCR = regVal;
00000024 1C0A MOV R2,R1 ; regVal
00000026 4800 LDR R0,=0xE0008004
00000028 6002 STR R2,[R0,#0x0]
107: }
0000002A L_8:
108: return;
0000002A ; SCOPE-END
109: }
0000002A 4770 BX R14
0000002C ENDP ; 'reset_timer?T'
*** CODE SEGMENT '?PR?init_timer?T?timer':
122: DWORD init_timer (void)
00000000 B500 PUSH {LR}
124: timer_counter = 0;
00000002 2100 MOV R1,#0x0
00000004 4800 LDR R0,=timer_counter ; timer_counter
00000006 6001 STR R1,[R0,#0x0] ; timer_counter
125: T0MR0 = INTERVAL_10MS; /* 10mSec = 150.000-1 counts */
00000008 4800 LDR R1,=0x249EF
0000000A 4800 LDR R0,=0xE0004018
0000000C 6001 STR R1,[R0,#0x0]
126: T0MCR = 3; /* Interrupt and Reset on MR0 */
0000000E 2103 MOV R1,#0x3
00000010 4800 LDR R0,=0xE0004014
00000012 6001 STR R1,[R0,#0x0]
127: if ( install_irq( TIMER0_INT, (void *)Timer0Handler ) == FALSE )
00000014 4900 LDR R1,=Timer0Handler?A ; Timer0Handler?A
00000016 2004 MOV R0,#0x4
00000018 F7FF BL install_irq?T ; T=0x0001 (1)
0000001A FFF2 BL install_irq?T ; T=0x0001 (2)
0000001C 2800 CMP R0,#0x0 ; install_irq?T
0000001E D101 BNE L_10 ; T=0x00000024
129: return (FALSE);
00000020 2000 MOV R0,#0x0
00000022 E000 B L_11 ; T=0x00000026
130: }
00000024 L_10:
133: return (TRUE);
00000024 2001 MOV R0,#0x1
135: }
00000026 L_11:
00000026 BC08 POP {R3}
00000028 4718 BX R3
0000002A ENDP ; 'init_timer?T'
Module Information Static
----------------------------------
code size = ------
data size = 4
const size = ------
End of Module Information.
ARM COMPILATION COMPLETE. 0 WARNING(S), 0 ERROR(S)
?? 快捷鍵說(shuō)明
復(fù)制代碼
Ctrl + C
搜索代碼
Ctrl + F
全屏模式
F11
切換主題
Ctrl + Shift + D
顯示快捷鍵
?
增大字號(hào)
Ctrl + =
減小字號(hào)
Ctrl + -