資源簡介
在STM8S003單片機最小系統上測試ADC多通道采樣功能,同時采樣AIN2、AIN3、AIN4、AIN5、AIN6通道輸入值,并計算各通道采樣平均值。

代碼片段和文件信息
#include?“iostm8s103F3.h“
#include?“main.h“
#include?“led.h“
#include?“adc.h“
#include?“stdio.h“
#include?“delay.h“
#include?“stdlib.h“
#include?“timer4.h“
#include?“uart.h“
u16??val2?=?0?val3?=?0?val4?=?0?val5?=?0val6?=?0;
void?SysClkInit(?void?)
{
????CLK_SWR?=?0xe1;?????????????????????????????//HSI為主時鐘源??16MHz?CPU時鐘頻率
????CLK_CKDIVR?=?0x00;??????????????????????????//CPU時鐘0分頻,系統時鐘0分頻
}
void?main(?void?)
{
????__asm(?“sim“?);?????????????????????????????//禁止中斷
????SysClkInit();
????delay_init(?16?);
????LED_GPIO_Init();
????ADC_GPIO_Init();
????ADC_CH_Init(?3?);
????__asm(?“rim“?);?????????????????????????????//開啟中斷
????while(?1?)
????{
????????
????????val2?=?get_ave(?2?);????????????????????//PC4?AIN2
????????val3?=?get_ave(?3?);????????????????????//PD2?AIN3
????????val4?=?get_ave(?4?);????????????????????//PD3?AIN4
????????val5?=?get_ave(?5?);????????????????????//PD5?AIN5
????????val6?=?get_ave(?6?);????????????????????//PD6?AIN6
????}
}
?屬性????????????大小?????日期????時間???名稱
-----------?---------??----------?-----??----
?????目錄???????????0??2019-07-08?17:50??Adc_Ave_TestV0.4\
?????文件????????2397??2018-05-15?14:52??Adc_Ave_TestV0.4\BuildLog.log
?????目錄???????????0??2019-07-08?08:31??Adc_Ave_TestV0.4\Debug\
?????目錄???????????0??2019-07-08?17:50??Adc_Ave_TestV0.4\Debug\Exe\
?????文件????????3170??2019-07-08?17:50??Adc_Ave_TestV0.4\Debug\Exe\adc.hex
?????文件???????53160??2019-07-08?17:50??Adc_Ave_TestV0.4\Debug\Exe\power_soft.out
?????目錄???????????0??2019-07-08?17:50??Adc_Ave_TestV0.4\Debug\List\
?????文件???????18559??2019-07-08?17:50??Adc_Ave_TestV0.4\Debug\List\power_soft.map
?????目錄???????????0??2019-07-08?17:51??Adc_Ave_TestV0.4\Debug\Obj\
?????文件???????21621??2019-07-08?17:48??Adc_Ave_TestV0.4\Debug\Obj\adc.o
?????文件??????302491??2019-07-08?17:48??Adc_Ave_TestV0.4\Debug\Obj\adc.pbi
?????文件???????11779??2019-07-08?17:48??Adc_Ave_TestV0.4\Debug\Obj\adc.pbi.xcl
?????文件????????9011??2019-07-08?17:46??Adc_Ave_TestV0.4\Debug\Obj\delay.o
?????文件????????1687??2019-07-08?17:44??Adc_Ave_TestV0.4\Debug\Obj\delay.pbi
?????文件???????11781??2019-07-08?17:44??Adc_Ave_TestV0.4\Debug\Obj\delay.pbi.xcl
?????文件???????16405??2019-07-08?17:46??Adc_Ave_TestV0.4\Debug\Obj\led.o
?????文件??????225836??2019-07-08?17:44??Adc_Ave_TestV0.4\Debug\Obj\led.pbi
?????文件???????11779??2019-07-08?17:44??Adc_Ave_TestV0.4\Debug\Obj\led.pbi.xcl
?????文件???????10412??2019-07-08?17:50??Adc_Ave_TestV0.4\Debug\Obj\main.o
?????文件??????275518??2019-07-08?17:50??Adc_Ave_TestV0.4\Debug\Obj\main.pbi
?????文件???????11771??2019-07-08?17:50??Adc_Ave_TestV0.4\Debug\Obj\main.pbi.xcl
?????文件??????327059??2019-07-08?17:51??Adc_Ave_TestV0.4\Debug\Obj\power_soft.pbd
?????文件??????327059??2019-07-08?17:51??Adc_Ave_TestV0.4\Debug\Obj\power_soft.pbd.browse
?????文件?????????402??2019-07-08?17:51??Adc_Ave_TestV0.4\Debug\Obj\power_soft.pbd.linf
?????文件???????10818??2019-07-08?17:46??Adc_Ave_TestV0.4\Debug\Obj\timer4.o
?????文件??????225268??2019-07-08?17:44??Adc_Ave_TestV0.4\Debug\Obj\timer4.pbi
?????文件???????11782??2019-07-08?17:44??Adc_Ave_TestV0.4\Debug\Obj\timer4.pbi.xcl
?????文件???????19849??2019-07-08?17:46??Adc_Ave_TestV0.4\Debug\Obj\uart.o
?????文件??????227323??2019-07-08?17:44??Adc_Ave_TestV0.4\Debug\Obj\uart.pbi
?????文件???????11780??2019-07-08?17:44??Adc_Ave_TestV0.4\Debug\Obj\uart.pbi.xcl
?????目錄???????????0??2019-07-08?17:48??Adc_Ave_TestV0.4\HardWare\
............此處省略38個文件信息
評論
共有 條評論