?? adctimer.lst
字號(hào):
ARM COMPILER V2.53, ADCtimer 10/12/07 17:24:07 PAGE 1
ARM COMPILER V2.53, COMPILATION OF MODULE ADCtimer
OBJECT MODULE PLACED IN ADCtimer.OBJ
COMPILER INVOKED BY: d:\Keil\ARM\BIN\CA.exe ADCtimer.c THUMB DEBUG TABS(4)
stmt level source
1 /*********************************************************************
2
3 Author : ADI - Apps www.analog.com/MicroConverter
4
5 Date : Sept. 2005
6
7 File : ADCtimer.c
8
9 Hardware : Applicable to ADuC702x rev H or I silicon
10 Currently targetting ADuC7026.
11
12 Description : Performs an ADC conversion every 91 us using timer0
13 overflow alternatively on Channel 0 and 1
14 sending the results through UART at 9600bps
15
16 *********************************************************************/
17
18 #include <ADuC7026.h> // Include ADuC7026 Header File
19
20 void IRQ_Handler(void) __irq; // IRQ Funtion Prototype
21
22 void senddata(short to_send);
23 void ADCpoweron(int);
24 char hex2ascii(char toconv);
25 void delay(int);
26
27
28 int main (void) {
29 1
30 1 ADCpoweron(20000); // power on ADC
31 1 ADCCP = 0x00;
32 1 ADCCON = 0x6E2; // start conversion on timer 0
33 1
34 1 REFCON = 0x01; // connect internal 2.5V reference to VREF pin
35 1
36 1 GP1CON = 0x011; // Setup tx & rx pins on P1.0 and P1.1
37 1
38 1 // Setting up UART at 9600bps (CD=0)
39 1 COMCON0 = 0x80; // Setting DLAB
40 1 COMDIV0 = 0x88;
41 1 COMDIV1 = 0x00;
42 1 COMCON0 = 0x07; // Clearing DLAB
43 1
44 1
45 1 // for test purposes only
46 1 GP0CON = 0x10100000; // enable ECLK output on P0.7, and ADCbusy on P0.5
47 1
48 1
49 1 IRQEN = ADC_BIT; // Enable ADC IRQ ( 0x80 )
50 1
51 1 // timer0 configuration
52 1 T0LD = 35530; // 23.4us
53 1 T0CON = 0xC8; // count down
54 1 // periodic mode
55 1
56 1 GP4DAT = 0x04000000; // Configure P4.2 as output
57 1
58 1 while(1)
59 1 {
ARM COMPILER V2.53, ADCtimer 10/12/07 17:24:07 PAGE 2
60 2
61 2 }
62 1
63 1 return 0 ;
64 1 }
65
66
67 /********************************************************************/
68 /* */
69 /* Interrupt Service Rountine */
70 /* */
71 /********************************************************************/
72
73 void IRQ_Handler() __irq
74 {
75 1 GP4DAT ^= 0x00040000; // Complement P4.2
76 1 // ADCCP ^= 1; // change channel
77 1 senddata (ADCDAT >> 16);
78 1 return ;
79 1 }
80
81 void senddata(short to_send)
82 {
83 1 while(!(0x020==(COMSTA0 & 0x020))){}
84 1 COMTX = 0x0A; // output LF
85 1 while(!(0x020==(COMSTA0 & 0x020))){}
86 1 COMTX = 0x0D; // output CR
87 1 while(!(0x020==(COMSTA0 & 0x020))){}
88 1 COMTX = hex2ascii ((to_send >> 8) & 0x0F);
89 1 while(!(0x020==(COMSTA0 & 0x020))){}
90 1 COMTX = hex2ascii ((to_send >> 4) & 0x0F);
91 1 while(!(0x020==(COMSTA0 & 0x020))){}
92 1 COMTX = hex2ascii (to_send & 0x0F);
93 1 }
94
95
96 char hex2ascii(char toconv)
97 {
98 1 if (toconv<0x0A) toconv += 0x30;
99 1 else toconv += 0x37;
100 1 return (toconv);
101 1 }
102
103 void delay (int length)
104 {
105 1 while (length >=0)
106 1 length--;
107 1 }
108
109 void ADCpoweron(int time)
110 {
111 1 ADCCON = 0x20; // power-on the ADC
112 1 while (time >=0) // wait for ADC to be fully powered on
113 1 time--;
114 1 }
ARM COMPILER V2.53, ADCtimer 10/12/07 17:24:07 PAGE 3
ASSEMBLY LISTING OF GENERATED OBJECT CODE
*** EXTERNALS:
EXTERN NUMBER (__startup)
*** PUBLICS:
PUBLIC IRQ_Handler?A
PUBLIC senddata?T
PUBLIC senddata?A
PUBLIC ADCpoweron?T
PUBLIC hex2ascii?T
PUBLIC delay?T
PUBLIC main
*** CODE SEGMENT '?PR?main?ADCtimer':
28: int main (void) {
00000000 B500 PUSH {LR}
30: ADCpoweron(20000); // power on ADC
00000002 4800 LDR R0,=0x4E20
00000004 F7FF BL ADCpoweron?T ; T=0x0001 (1)
00000006 FFFC BL ADCpoweron?T ; T=0x0001 (2)
31: ADCCP = 0x00;
00000008 2200 MOV R2,#0x0
0000000A 4800 LDR R0,=0xFFFF0504
0000000C 6002 STR R2,[R0,#0x0]
32: ADCCON = 0x6E2; // start conversion on timer 0
0000000E 4800 LDR R1,=0x6E2
00000010 4800 LDR R0,=0xFFFF0500
00000012 6001 STR R1,[R0,#0x0]
34: REFCON = 0x01; // connect internal 2.5V reference to VREF pin
00000014 2101 MOV R1,#0x1
00000016 4800 LDR R0,=0xFFFF048C
00000018 6001 STR R1,[R0,#0x0]
36: GP1CON = 0x011; // Setup tx & rx pins on P1.0 and P1.1
0000001A 2111 MOV R1,#0x11
0000001C 4800 LDR R0,=0xFFFFF404
0000001E 6001 STR R1,[R0,#0x0]
39: COMCON0 = 0x80; // Setting DLAB
00000020 2180 MOV R1,#0x80
00000022 4800 LDR R0,=0xFFFF070C
00000024 6001 STR R1,[R0,#0x0]
40: COMDIV0 = 0x88;
00000026 2388 MOV R3,#0x88
00000028 4800 LDR R0,=0xFFFF0700
0000002A 6003 STR R3,[R0,#0x0]
41: COMDIV1 = 0x00;
0000002C 4800 LDR R0,=0xFFFF0704
0000002E 6002 STR R2,[R0,#0x0]
42: COMCON0 = 0x07; // Clearing DLAB
00000030 2207 MOV R2,#0x7
00000032 4800 LDR R0,=0xFFFF070C
00000034 6002 STR R2,[R0,#0x0]
46: GP0CON = 0x10100000; // enable ECLK output on P0.7, and ADCbusy on P0.5
00000036 4800 LDR R2,=0x10100000
00000038 4800 LDR R0,=0xFFFFF400
0000003A 6002 STR R2,[R0,#0x0]
49: IRQEN = ADC_BIT; // Enable ADC IRQ ( 0x80 )
0000003C 4800 LDR R0,=0xFFFF0008
0000003E 6001 STR R1,[R0,#0x0]
52: T0LD = 35530; // 23.4us
00000040 4800 LDR R1,=0x8ACA
00000042 4800 LDR R0,=0xFFFF0300
00000044 6001 STR R1,[R0,#0x0]
53: T0CON = 0xC8; // count down
00000046 21C8 MOV R1,#0xC8
ARM COMPILER V2.53, ADCtimer 10/12/07 17:24:07 PAGE 4
00000048 4800 LDR R0,=0xFFFF0308
0000004A 6001 STR R1,[R0,#0x0]
56: GP4DAT = 0x04000000; // Configure P4.2 as output
0000004C 4800 LDR R1,=0x4000000
?? 快捷鍵說(shuō)明
復(fù)制代碼
Ctrl + C
搜索代碼
Ctrl + F
全屏模式
F11
切換主題
Ctrl + Shift + D
顯示快捷鍵
?
增大字號(hào)
Ctrl + =
減小字號(hào)
Ctrl + -