📄 ad.lst
字号:
C51 COMPILER V7.10 AD 03/08/2008 14:40:59 PAGE 1
C51 COMPILER V7.10, COMPILATION OF MODULE AD
OBJECT MODULE PLACED IN ad.OBJ
COMPILER INVOKED BY: C:\silabs\IDEfiles\C51\BIN\C51.exe ad.c DB OE
line level source
1
2 #include <c8051f200.h> // SFR declarations
3
4 //------------------------------------------------------------------------------------
5 // 16-bit SFR Definitions for 'F2xx
6 //------------------------------------------------------------------------------------
7
8 sfr16 DP = 0x82; // data pointer
9 sfr16 ADC0 = 0xbe; // ADC0 data
10 sfr16 ADC0GT = 0xc4; // ADC0 greater than window
11 sfr16 ADC0LT = 0xc6; // ADC0 less than window
12 sfr16 RCAP2 = 0xca; // Timer2 capture/reload
13 sfr16 T2 = 0xcc; // Timer2
14
15 //------------------------------------------------------------------------------------
16 // Global CONSTANTS
17 //------------------------------------------------------------------------------------
18
19 sbit RUN_LED = P2^5;
20 sbit audioclk = P2^4;
21 //------------------------------------------------------------------------------------
22 // Global VARIABLE
23 //------------------------------------------------------------------------------------
24 //------------------------------------------------------------------------------------
25 // Function PROTOTYPES
26 //------------------------------------------------------------------------------------
27 void Timer2_ISR (void);
28 //------------------------------------------------------------------------------------
29 // MAIN Routine
30 //------------------------------------------------------------------------------------
31 void main (void) {
32 1 unsigned char audiodata;
33 1 // disable watchdog timer
34 1 WDTCN = 0xde;
35 1 WDTCN = 0xad;
36 1 OSCICN |=2;// : Internal Oscillator typical frequency is 8MHz.
37 1 PRT2CF |= 0x30; // enable P2.5 (LED) as push-pull output//enable p2.4 as output
38 1 PRT0CF = 0xff; // enable P0 as push-pull output
39 1 PRT1CF |= 0x80; //enable p1.7 as output
40 1 // Init Timer2 gto generate interrupts // at a 8kHz rate.
41 1 // Configure Timer2 to auto-reload and generate an interrupt at interval
42 1 // specified by <T2_counts> using SYSCLK/12 as its time base.
43 1 T2CON = 0x00; // Stop Timer2; configure for auto-reload
44 1 CKCON &= ~0x20; // T2M=0 (use SYSCLK/12 as timebase)
45 1 RCAP2 = -83;//8000000/12/8000; // Init reload value
46 1 T2 = 0xffff; // set to reload immediately
47 1 ET2 = 1; // enable Timer2 interrupts
48 1 TR2 = 1; // start Timer2
49 1 //AD init
50 1 AMX0SL = 0x28;//0010 1000 select p1.0 for AD input
51 1 ADC0CF = 0x62;//0110 0011 conversion clock is 1MHz, Gain is 4
52 1 //Bits2-0: 000: Gain = 1/ 001: Gain = 2/ 010: Gain = 4/ 011: Gain = 8/ 10x: Gain = 16/ 11x: Gain = 0.5
53 1 ADC0CN = 0xcc;//1100 1100
54 1 REF0CN = 0x03;// select VDD as the refer Voltage
55 1
C51 COMPILER V7.10 AD 03/08/2008 14:40:59 PAGE 2
56 1 EA = 1; // enable global interrupts
57 1 audioclk = 0;
58 1 while (1) {
59 2 if(ADCINT==1)
60 2 {
61 3 ADCINT=0;
62 3 audiodata=ADC0H;
63 3 P0 =audiodata;
64 3 audioclk=1;
65 3 audioclk=0;
66 3 }
67 2 }
68 1 }
69
70
71 //------------------------------------------------------------------------------------
72 // Interrupt Service Routines
73 //------------------------------------------------------------------------------------
74 //------------------------------------------------------------------------------------
75 // Timer2_ISR
76 //------------------------------------------------------------------------------------
77 // This routine .
78 //
79 void Timer2_ISR (void) interrupt 5
80 {
81 1 static unsigned int runc=0;
82 1 TF2 = 0; // clear Timer2 overflow interrupt flag
83 1 runc++;
84 1 //run light: if is the lo then light, if is the ho then flash
85 1 if (runc>=4000){
86 2 runc=0;
87 2 RUN_LED = ~RUN_LED;
88 2 }
89 1 }
90
91
MODULE INFORMATION: STATIC OVERLAYABLE
CODE SIZE = 107 ----
CONSTANT SIZE = ---- ----
XDATA SIZE = ---- ----
PDATA SIZE = ---- ----
DATA SIZE = 2 ----
IDATA SIZE = ---- ----
BIT SIZE = ---- ----
END OF MODULE INFORMATION.
C51 COMPILATION COMPLETE. 0 WARNING(S), 0 ERROR(S)
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -