📄 main.lst
字号:
ARM COMPILER V2.00f, main 20/02/05 14:21:05 PAGE 1
ARM COMPILER V2.00f, COMPILATION OF MODULE main
OBJECT MODULE PLACED IN main.OBJ
COMPILER INVOKED BY: C:\Keil\ARM\BIN\CA.exe main.c THUMB OPTIMIZE(7,SPEED) BROWSE DEBUG TABS(4)
stmt level source
1 /************************************************************/
2 /* PROJECT NAME: CANRX */
3 /* Project: LPC2100 Training course */
4 /* Engineer: T Martin tmartin@hitex.co.uk */
5 /* Filename: main.c */
6 /* Language: C */
7 /* Compiler: Keil ARM V2.00b */
8 /* Assembler: */
9 /* */
10 /************************************************************/
11 /* COPYRIGHT: Hitex UK Ltd 2005 */
12 /* LICENSE: THIS VERSION CREATED FOR FREE DISTRIBUTION */
13 /************************************************************/
14 /* Function: CAN Transmit example */
15 /* */
16 /* Example */
17 /* */
18 /* Demonstrates Transmiting a CAN packet */
19 /* */
20 /* */
21 /* Oscillator frequency 12.000 Mhz */
22 /* Target board Keil MCB21000 */
23 /************************************************************/
24
25 #include <LPC21xx.H>
26 extern void InitCAN1(void);
27
28 int main(void)
29 {
30 1 unsigned val = 0;
31 1
32 1 VPBDIV = 0x00000001; //Set PClk to 60Mhz
33 1 ADCR = 0x00270601; //Setup A/D: 10-bit AIN0 @ 3MHz
34 1 ADCR |= 0x01000000; //Start A/D Conversion
35 1
36 1
37 1 PINSEL1 |= 0x00014000; //Enable Pin 0.25 as CAN1 RX
38 1 C2MOD = 0x00000001; //Set CAN controller into reset
39 1 C2BTR = 0x001C001D; //Set bit timing to 125k
40 1 C2MOD = 0x00000000; //Release CAN controller
41 1
42 1 InitCAN1(); //initilise CAN controller 1 ( see next example)
43 1
44 1 while(1)
45 1 {
46 2
47 2 C2TFI1 = 0x00040000; //Set DLC to 4 bytes
48 2 C2TID1 = 0x00000002; //Set address to 2 Standard Frame
49 2
50 2 do
51 2 {
52 3 val = ADDR; // Read A/D Data Register
53 3 }
54 2 while ((val & 0x80000000) == 0);
55 2 //A to D conversion
56 2
57 2 if(C2SR & 0x00000004) //See if Tx Buffer 1 is free
58 2 {
59 3
ARM COMPILER V2.00f, main 20/02/05 14:21:05 PAGE 2
60 3 C2TDA1 = val; //Copy A/D result into first four bytes
61 3 C2CMR = 0x00000021; //Transmit the message
62 3 }
63 2 }
64 1
65 1 }
66
67
ARM COMPILER V2.00f, main 20/02/05 14:21:05 PAGE 3
ASSEMBLY LISTING OF GENERATED OBJECT CODE
*** EXTERNALS:
EXTERN CODE16 (InitCAN1?T)
EXTERN NUMBER (__startup)
*** PUBLICS:
PUBLIC main
*** CODE SEGMENT '?PR?main?main':
28: int main(void)
00000000 B500 PUSH {LR}
29: {
00000002 ; SCOPE-START
32: VPBDIV = 0x00000001; //Set PClk to 60Mhz
00000002 2101 MOV R1,#0x1
00000004 4800 LDR R0,=0xE01FC100
00000006 7001 STRB R1,[R0,#0x0]
33: ADCR = 0x00270601; //Setup A/D: 10-bit AIN0 @ 3MHz
00000008 4800 LDR R1,=0x270601
0000000A 4800 LDR R0,=0xE0034000
0000000C 6001 STR R1,[R0,#0x0]
34: ADCR |= 0x01000000; //Start A/D Conversion
0000000E 4800 LDR R2,=0x1000000
00000010 4800 LDR R0,=0xE0034000
00000012 6801 LDR R1,[R0,#0x0]
00000014 4311 ORR R1,R2
00000016 6001 STR R1,[R0,#0x0]
37: PINSEL1 |= 0x00014000; //Enable Pin 0.25 as CAN1 RX
00000018 4800 LDR R2,=0x14000
0000001A 4800 LDR R0,=0xE002C004
0000001C 6801 LDR R1,[R0,#0x0]
0000001E 4311 ORR R1,R2
00000020 6001 STR R1,[R0,#0x0]
38: C2MOD = 0x00000001; //Set CAN controller into reset
00000022 2101 MOV R1,#0x1
00000024 4800 LDR R0,=0xE0048000
00000026 6001 STR R1,[R0,#0x0]
39: C2BTR = 0x001C001D; //Set bit timing to 125k
00000028 4800 LDR R1,=0x1C001D
0000002A 4800 LDR R0,=0xE0048014
0000002C 6001 STR R1,[R0,#0x0]
40: C2MOD = 0x00000000; //Release CAN controller
0000002E 2100 MOV R1,#0x0
00000030 4800 LDR R0,=0xE0048000
00000032 6001 STR R1,[R0,#0x0]
42: InitCAN1(); //initilise CAN controller 1 ( see next example)
00000034 F7FF BL InitCAN1?T ; T=0x0001 (1)
00000036 FFE4 BL InitCAN1?T ; T=0x0001 (2)
44: while(1)
0000003A L_3:
47: C2TFI1 = 0x00040000; //Set DLC to 4 bytes
0000003A 4800 LDR R1,=0x40000
0000003C 4800 LDR R0,=0xE0048030
0000003E 6001 STR R1,[R0,#0x0]
48: C2TID1 = 0x00000002; //Set address to 2 Standard Frame
00000040 2102 MOV R1,#0x2
00000042 4800 LDR R0,=0xE0048034
00000044 6001 STR R1,[R0,#0x0]
50: do
00000046 L_5:
52: val = ADDR; // Read A/D Data Register
00000046 4800 LDR R0,=0xE0034004
00000048 6801 LDR R1,[R0,#0x0]
0000004A ---- Variable 'val' assigned to Register 'R1' ----
ARM COMPILER V2.00f, main 20/02/05 14:21:05 PAGE 4
53: }
0000004A 4800 LDR R0,=0x80000000
0000004C 4201 TST R1,R0 ; val
0000004E D0FA BEQ L_5 ; T=0x00000046
57: if(C2SR & 0x00000004) //See if Tx Buffer 1 is free
00000050 4800 LDR R0,=0xE004801C
00000052 6800 LDR R0,[R0,#0x0]
00000054 2204 MOV R2,#0x4
00000056 4210 TST R0,R2
00000058 D0EF BEQ L_3 ; T=0x0000003A
60: C2TDA1 = val; //Copy A/D result into first four bytes
0000005A 4800 LDR R0,=0xE0048038
0000005C 6001 STR R1,[R0,#0x0]
61: C2CMR = 0x00000021; //Transmit the message
0000005E 2121 MOV R1,#0x21
00000060 4800 LDR R0,=0xE0048004
00000062 6001 STR R1,[R0,#0x0]
63: }
00000064 E7E9 B L_3 ; T=0x0000003A
00000066 ; SCOPE-END
00000066 BC08 POP {R3}
00000068 4718 BX R3
0000006A 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 + -