#include "led.h"
#include "delay.h"
#include "sys.h"
#include "usart.h"
#include "lcd.h"
#include "adc.h"
//ALIENTEK Mini STM32开发板范例代码15
//ADC实验
//技术支持:
www.openedv.com
//广州市星翼电子科技有限公司
u8 Buf[30];
u8 Buf1[30];
u8 Buf2[30];
u8 Buf3[30];
int main(void)
{
u32 adcx=0;
u32 adcx1=0;
u32 adcx2=0;
//u32 Vol4=0;
float Vol=0;
float Vol1=0;
float Vol2=0;
float Vol3=0;
float dianliang=0;
delay_init(); //延时函数初始化
uart_init(9600); //串口初始化为9600
LED_Init(); //初始化与LED连接的硬件接口
LCD_Init();
Adc_Init(); //ADC初始化
POINT_COLOR=RED;//设置字体为红 {MOD}
LCD_ShowString(60,50,200,16,16,"Mini STM32");
LCD_ShowString(60,70,200,16,16,"ADC TEST");
LCD_ShowString(60,90,200,16,16,"ATOM@ALIENTEK");
LCD_ShowString(60,110,200,16,16,"2014/3/9");
//显示提示信息
POINT_COLOR=BLUE;//设置字体为蓝 {MOD}
LCD_ShowString(60,130,200,16,16,"ADC_CH1_VAL:");
LCD_ShowString(60,150,200,16,16,"ADC_CH1_VOL:0.000V");
LCD_ShowString(60,170,200,16,16,"ADC_CH2_VOL:0.000V");
LCD_ShowString(60,190,200,16,16,"ADC_CH3_VOL:0.000V");
LCD_ShowString(60,210,200,16,16,"ADC_CH3_ADD:0.000V");
while(1)
{
adcx+=Get_Adc_Average(ADC_Channel_1,10);
LCD_ShowxNum(156,130,adcx,4,16,0);//显示ADC的值
Vol=(float)adcx*3.3/4096;
sprintf((char*)Buf,"%.3fV ",Vol);
LCD_ShowString(156,150,200,16,16,Buf);
adcx1+=Get_Adc_Average1(ADC_Channel_2,10);
LCD_ShowxNum(156,130,adcx1,4,16,0);//显示ADC的值
Vol1=(float)adcx1*3.3/4096;
sprintf((char*)Buf1,"%.3fV ",Vol1);
LCD_ShowString(156,170,200,16,16,Buf1);
adcx2=Get_Adc_Average2(ADC_Channel_3,10);
LCD_ShowxNum(156,130,adcx2,4,16,0);//显示ADC的值
Vol2=(float)adcx2*3.3/4096;
sprintf((char*)Buf2,"%.3fV ",Vol2);
LCD_ShowString(156,190,200,16,16,Buf2);
dianliang=Vol1*Vol2;
LCD_ShowxNum(156,130,dianliang,4,16,0);//显示ADC的值
Vol3=(float)dianliang*3.3/4.096;
sprintf((char*)Buf3,"%.3fV ",Vol3);
LCD_ShowString(156,210,200,16,16,Buf3);
LED0=!LED0;
delay_ms(100);
}
}
这个是主程序。。。。
这个就有点尴尬了。。。
一周热门 更多>