ct_test/Keil_C/List/adc.lst

117 lines
5.1 KiB
Plaintext
Raw Permalink Blame History

This file contains invisible Unicode characters

This file contains invisible Unicode characters that are indistinguishable to humans but may be processed differently by a computer. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

C51 COMPILER V9.59.0.0 ADC 01/18/2024 10:03:11 PAGE 1
C51 COMPILER V9.59.0.0, COMPILATION OF MODULE ADC
OBJECT MODULE PLACED IN ..\Output\adc.obj
COMPILER INVOKED BY: D:\Keil_v5\C51\BIN\C51.EXE ..\Apps\adc.c LARGE OBJECTADVANCED OPTIMIZE(8,SIZE) BROWSE INCDIR(..\FWL
-ib\SC92F_Lib\inc;..\User;..\Apps;..\Apps;..\User) DEFINE(SC92F836xB) DEBUG PRINT(..\List\adc.lst) OBJECT(..\Output\adc.o
-bj)
line level source
1 #include "SC_Init.h" //MCU Init headerInclude all IC resource headers
2 #include "SC_it.h"
3 #include "..\Drivers\SCDriver_list.h"
4 #include "HeadFiles\SysFunVarDefine.h"
5
6 #include "adc.h"
7 #include "Uart1.h"
8
9 unsigned int xdata ADC_Value0 = 0,ADC_Value1 = 0,ADC_Value2 = 0;
10
11 unsigned int xdata ADC_NUM1=0;
12 //获取adc转换数值
13 unsigned int ADC_Convert(void)
14 {
15 1 unsigned int xdata Tad = 0,MinAd1 = 0x0fff,MaxAd1 = 0x0000,MinAd2 = 0x0fff,MaxAd2 = 0x0000,TempAdd =
-0;
16 1 unsigned char xdata t = 0;
17 1 for(t = 0;t < 10;t++)
18 1 {
19 2 ADCCON |= 0X40; //开始 ADC 转换
20 2 while(!(ADCCON & 0x20));//等待 ADC 转换完成,不同型号的转换完成标志位位置不同,部分型号在 Bit5,部分型号<E59E8B>
-贐it4,具体请参照规格。
21 2 //清中断标志位
22 2 ADCCON &= ~(0X20);
23 2 Tad = ((unsigned int)ADCVH << 4) + (ADCVL >> 4); //取得一次转换值
24 2 ADC_NUM1=Tad;
25 2 if(Tad > MaxAd1)
26 2 {
27 3 MaxAd1 = Tad;//获得当前的最大值
28 3 }
29 2 // else
30 2 // {
31 2 // if(Tad > MaxAd2)
32 2 // MaxAd2 = Tad;
33 2 // }
34 2 if (Tad < MinAd1)
35 2 {
36 3 MinAd1 = Tad;//获得当前的最小值
37 3 }
38 2 // else
39 2 // {
40 2 // if(Tad > MinAd2)
41 2 // MinAd2 = Tad;
42 2 // }
43 2 TempAdd += Tad;
44 2 }
45 1
46 1 //转换值累加
47 1 TempAdd -= MinAd1;//去掉最小值
48 1 TempAdd -= MaxAd1;//去掉最大值
49 1 // TempAdd -= MinAd2;//去掉第二最小值
50 1 // TempAdd -= MaxAd2;//去掉第二最大值
51 1 //TempAdd = TempAdd / 16;
C51 COMPILER V9.59.0.0 ADC 01/18/2024 10:03:11 PAGE 2
52 1 TempAdd >>= 3; //求平均值
53 1 return TempAdd;
54 1 }
55
56 //切换ADC入口
57 void ADC_channel(unsigned char ADC_Channel)
58 {
59 1 ADCCFG0 = 0x07;
60 1 ADCCON = 0xE0 | ADC_Channel;
61 1 }
62
63 extern uint8_t xdata motor_data[];
64 void ADC_Multichannel(void)
65 {
66 1 uint8_t xdata temp_h,temp_l; //定义高八位和低八位
67 1
68 1 ADC_channel(1); //ADC 入口切换至 AIN1 口,采集电压信号
69 1 ADC_Value1 = ADC_Convert(); //启动 ADC 转换,获得转换值
70 1 temp_h = (ADC_Value1 & 0xff00) >> 8;//高8位的值
71 1 temp_l = ADC_Value1 & 0x00ff; //低8位的值
72 1 motor_data[4] = temp_h;
73 1 motor_data[5] = temp_l;
74 1
75 1 ADC_channel(2); //ADC 入口切换至 AIN2 口,采集激光测距信号
76 1 ADC_Value2 = ADC_Convert(); //启动 ADC 转换,获得转换值
77 1 temp_h = (ADC_Value2 & 0xff00) >> 8;//高8位的值
78 1 temp_l = ADC_Value2 & 0x00ff; //低8位的值
79 1 motor_data[6] = temp_h;
80 1 motor_data[7] = temp_l;
81 1 }
82
83
MODULE INFORMATION: STATIC OVERLAYABLE
CODE SIZE = 295 ----
CONSTANT SIZE = ---- ----
XDATA SIZE = 8 10
PDATA SIZE = ---- ----
DATA SIZE = ---- ----
IDATA SIZE = ---- ----
BIT SIZE = ---- ----
EDATA SIZE = ---- ----
HDATA SIZE = ---- ----
XDATA CONST SIZE = ---- ----
FAR CONST SIZE = ---- ----
END OF MODULE INFORMATION.
C51 COMPILATION COMPLETE. 0 WARNING(S), 0 ERROR(S)