📄 main.lst
字号:
ARM COMPILER V2.53, main 26/12/07 18:22:03 PAGE 1
ARM COMPILER V2.53, COMPILATION OF MODULE main
OBJECT MODULE PLACED IN main.OBJ
COMPILER INVOKED BY: d:\Keil\ARM\BIN\CA.exe main.c THUMB OPTIMIZE(7,SPEED) BROWSE DEBUG TABS(4)
stmt level source
1 /************************************************************/
2 /* PROJECT NAME: PWM */
3 /* Project: LPC2100 Training course */
4 /* Engineer: T Martin */
5 /* Filename: main.c */
6 /* Language: C */
7 /* Compiler: Keil Carm 2.00b */
8 /* Assembler: */
9 /* */
10 /************************************************************/
11 /* Modification History: */
12 /* */
13 /************************************************************/
14 /* Function: */
15 /* */
16 /* Example PWM module program for LPC2100 */
17 /* */
18 /* Demonstrates dual edge PWM generation */
19 /* */
20 /* Oscillator frequency 12.000 Mhz */
21 /* Target board Keil MCB2100 */
22 /************************************************************/
23
24
25
26
27 #include <LPC21XX.H>
28
29 int main(void)
30 {
31 1 unsigned int val,delay;
32 1
33 1 PINSEL0 |= 0x00028000; //Enable pin 0.7 as PWM2
34 1 PWMPR = 0x00000001; //Load prescaler
35 1
36 1 PWMPCR = 0x0000404; //PWM channel 2 double edge control, output enabled
37 1 PWMMCR = 0x00000002; //On match with timer reset the counter
38 1 PWMMR0 = 0x000000FF; //set cycle rate to sixteen ticks
39 1 PWMMR1 = 0x00000080; //set rising edge of PWM2 to 2 ticks
40 1 PWMMR2 = 0x00000080; //set falling edge of PWM2 to 8 ticks
41 1 PWMLER = 0x00000007; //enable shadow latch for match 0 - 2
42 1 //PWMEMR = 0x00000280; //Match 1 and Match 2 outputs set high
43 1 PWMTCR = 0x00000002; //Reset counter and prescaler
44 1 PWMTCR = 0x00000009; //enable counter and PWM, release counter from reset
45 1
46 1 ADCR = 0x00250601; // Setup A/D: 10-bit AIN0 @ 3MHz
47 1 ADCR |= 0x01000000; // Start A/D Conversion
48 1
49 1 while(1) // main loop
50 1 {
51 2 for (delay=0;delay < 0x100;delay++)
52 2 {
53 3 ;
54 3 }
55 2 do
56 2 {
57 3 val = ADDR; // Read A/D Data Register
58 3 }
59 2 while ((val & 0x80000000) == 0); //Wait for the conversion to complete
ARM COMPILER V2.53, main 26/12/07 18:22:03 PAGE 2
60 2 val = ((val >> 8) & 0x00FF); //Extract the A/D result
61 2
62 2 PWMMR1 = 0x00000000+val; //Modulate PWM
63 2 PWMMR2 = 0x000000FF-val;
64 2 PWMLER = 0x00000006; //set latch to update PWM registers next cycle
65 2 }
66 1
67 1
68 1 }
69
70
71
ARM COMPILER V2.53, main 26/12/07 18:22:03 PAGE 3
ASSEMBLY LISTING OF GENERATED OBJECT CODE
*** EXTERNALS:
EXTERN NUMBER (__startup)
*** PUBLICS:
PUBLIC main
*** CODE SEGMENT '?PR?main?main':
29: int main(void)
00000000 B500 PUSH {LR}
30: {
00000002 ; SCOPE-START
33: PINSEL0 |= 0x00028000; //Enable pin 0.7 as PWM2
00000002 4800 LDR R2,=0x28000
00000004 4800 LDR R0,=0xE002C000
00000006 6801 LDR R1,[R0,#0x0]
00000008 4311 ORR R1,R2
0000000A 6001 STR R1,[R0,#0x0]
34: PWMPR = 0x00000001; //Load prescaler
0000000C 2101 MOV R1,#0x1
0000000E 4800 LDR R0,=0xE001400C
00000010 6001 STR R1,[R0,#0x0]
36: PWMPCR = 0x0000404; //PWM channel 2 double edge control, output enabled
00000012 4800 LDR R1,=0x404
00000014 4800 LDR R0,=0xE001404C
00000016 6001 STR R1,[R0,#0x0]
37: PWMMCR = 0x00000002; //On match with timer reset the counter
00000018 2102 MOV R1,#0x2
0000001A 4800 LDR R0,=0xE0014014
0000001C 6001 STR R1,[R0,#0x0]
38: PWMMR0 = 0x000000FF; //set cycle rate to sixteen ticks
0000001E 22FF MOV R2,#0xFF
00000020 4800 LDR R0,=0xE0014018
00000022 6002 STR R2,[R0,#0x0]
39: PWMMR1 = 0x00000080; //set rising edge of PWM2 to 2 ticks
00000024 2280 MOV R2,#0x80
00000026 4800 LDR R0,=0xE001401C
00000028 6002 STR R2,[R0,#0x0]
40: PWMMR2 = 0x00000080; //set falling edge of PWM2 to 8 ticks
0000002A 4800 LDR R0,=0xE0014020
0000002C 6002 STR R2,[R0,#0x0]
41: PWMLER = 0x00000007; //enable shadow latch for match 0 - 2
0000002E 2207 MOV R2,#0x7
00000030 4800 LDR R0,=0xE0014050
00000032 6002 STR R2,[R0,#0x0]
43: PWMTCR = 0x00000002; //Reset counter and prescaler
00000034 4800 LDR R0,=0xE0014004
00000036 6001 STR R1,[R0,#0x0]
44: PWMTCR = 0x00000009; //enable counter and PWM, release counter from reset
00000038 2109 MOV R1,#0x9
0000003A 4800 LDR R0,=0xE0014004
0000003C 6001 STR R1,[R0,#0x0]
46: ADCR = 0x00250601; // Setup A/D: 10-bit AIN0 @ 3MHz
0000003E 4800 LDR R1,=0x250601
00000040 4800 LDR R0,=0xE0034000
00000042 6001 STR R1,[R0,#0x0]
47: ADCR |= 0x01000000; // Start A/D Conversion
00000044 4800 LDR R2,=0x1000000
00000046 4800 LDR R0,=0xE0034000
00000048 6801 LDR R1,[R0,#0x0]
0000004A 4311 ORR R1,R2
0000004C 6001 STR R1,[R0,#0x0]
51: for (delay=0;delay < 0x100;delay++)
0000004E L_9:
ARM COMPILER V2.53, main 26/12/07 18:22:03 PAGE 4
0000004E 2000 MOV R0,#0x0
00000050 ---- Variable 'delay' assigned to Register 'R0' ----
54: }
00000050 L_5:
00000050 3001 ADD R0,#0x1
00000052 1C01 MOV R1,R0 ; delay
00000054 4A40 LDR R2,=0x100
00000056 4291 CMP R1,R2 ; delay
00000058 D3FA BCC L_5 ; T=0x00000050
55: do
0000005A L_10:
57: val = ADDR; // Read A/D Data Register
0000005A 4800 LDR R0,=0xE0034004
0000005C 6802 LDR R2,[R0,#0x0]
0000005E ---- Variable 'val' assigned to Register 'R2' ----
58: }
0000005E 1C10 MOV R0,R2 ; val
00000060 4800 LDR R1,=0x80000000
00000062 4208 TST R0,R1 ; val
00000064 D0F9 BEQ L_10 ; T=0x0000005A
60: val = ((val >> 8) & 0x00FF); //Extract the A/D result
00000066 0A12 LSR R2,R2,#0x8 ; val
00000068 21FF MOV R1,#0xFF
0000006A 400A AND R2,R1
62: PWMMR1 = 0x00000000+val; //Modulate PWM
0000006C 1C13 MOV R3,R2 ; val
0000006E 4800 LDR R0,=0xE001401C
00000070 6003 STR R3,[R0,#0x0]
63: PWMMR2 = 0x000000FF-val;
00000072 1C10 MOV R0,R2 ; val
00000074 1A09 SUB R1,R0 ; val
00000076 4800 LDR R0,=0xE0014020
00000078 6001 STR R1,[R0,#0x0]
64: PWMLER = 0x00000006; //set latch to update PWM registers next cycle
0000007A 2106 MOV R1,#0x6
0000007C 4800 LDR R0,=0xE0014050
0000007E 6001 STR R1,[R0,#0x0]
65: }
00000080 E7E5 B L_9 ; T=0x0000004E
00000082 ; SCOPE-END
68: }
00000082 BC08 POP {R3}
00000084 4718 BX R3
00000086 ENDP ; 'main'
Module Information Static
----------------------------------
code size = ------
data size = ------
const size = ------
End of Module Information.
ARM COMPILATION COMPLETE. 0 WARNING(S), 0 ERROR(S)
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -