stm32f103 adc 多通道采集
- /****************************************
- * 文件名 :main.c
- * 描述 :串口1(USART1)向電腦的超級終端以1s為間隔打印當前ADC1的轉換電壓值
- * 實驗平臺:MINI STM32開發板 基于STM32F103VET6
- * 庫版本 :ST3.0.0
- **********************************************************************************/
- #include "stm32f10x.h"
- #include "usart1.h"
- #include "adc.h"
- extern __IO u16 ADC_ConvertedValue;
- // 軟件延時
- void Delay(unsigned long time)
- {unsigned long i,j;
-
- for(j=0; j<time; j++)
- {
- for(i=0;i<12000;i++);
- }
- }
- int main(void)
- {
- u32 AD_value;
- /* 配置系統時鐘為72M */
- SystemInit();
- /* 配置串口 */
- USART1_Config();
- /* 初始化ADC1 */
- ADC1_Init();
- printf("\r\n -------這是一個ADC實驗------\r\n");
- printf("\r\n -------ADC采樣的是PA0口------\r\n");
- while (1)
- {
- Delay(500);
- AD_value = 3300000/4096*ADC_ConvertedValue/1000;
-
- printf("AD value = %d mV \r\n", AD_value);
- }
- }
復制代碼
全部資料51hei下載地址:
基本例程-ADC操作.7z
(141.35 KB, 下載次數: 33)
2020-2-29 12:46 上傳
點擊文件名下載附件
下載積分: 黑幣 -5
|