[mw_shl_code=applescript,true]#include "sys.h"
#include "delay.h"
#include "usart.h"
#include "led.h"
#include "lcd.h"
#include "adc.h"
#include "key.h"
#include "usmart.h"
#include "sram.h"
#include "timer.h"
int main(void)
{
u16 adcx;
float temp;
u16 shao=0;
u32 i=0;
Stm32_Clock_Init(336,8,2,7);//设置时钟,168Mhz
delay_init(168); //延时初始化
uart_init(84,115200); //初始化串口波特率为115200
LED_Init(); //初始化LED
LCD_Init(); //初始化LCD
Adc_Init(); //初始化ADC
KEY_Init(); //按键初始化
FSMC_SRAM_Init(); //初始化外部SRAM
usmart_dev.init(84); //初始化USMART
POINT_COLOR=RED;
LCD_ShowString(30,50,200,16,16,"Explorer STM32F4");
LCD_ShowString(30,70,200,16,16,"ADC TEST");
LCD_ShowString(30,90,200,16,16,"ATOM@ALIENTEK");
LCD_ShowString(30,110,200,16,16,"2014/5/6");
POINT_COLOR=BLUE;//设置字体为蓝 {MOD}
LCD_ShowString(30,130,200,16,16,"ADC1_CH5_VAL:");
LCD_ShowString(30,150,200,16,16,"ADC1_CH5_VOL:0.000V");
for(i=0;i<2500;i+=2)
{
adcx=Get_Adc_Average(ADC_CH5,20);
printf("%d
", adcx);
shao=adcx;
SRAMWriteBuffer(&shao,i,1);
LED0=!LED0;
delay_ms(4);
}
for(i=0;i<2500;i+=2)
{
SRAMReadBuffer(&shao,i,1);
temp=(float)shao*(3.3/4096);
//printf("%lf
", temp);
}
}
[/mw_shl_code]拜托高手们教教我怎么使用定时器写一个adc是250HZ的代码,我看了定时器的实验,但他只教怎么闪led灯,我把它改成 adcx=Get_Adc_Average(ADC_CH5,20);,但还是行不通
友情提示: 此问题已得到解决,问题已经关闭,关闭后问题禁止继续编辑,回答。
一周热门 更多>