[mw_shl_code=applescript,true]#include "sys.h"
#include "delay.h"
#include "usart.h"
#include "led.h"
#include "lcd.h"
#include "adc.h"
#include "dac.h"
#include "key.h"
//ALIENTEK ì½Ë÷ÕßSTM32F407¿a·¢°å êμÑé21
//DACêμÑé-¿aoˉêy°æ±¾
//¼¼êõÖ§3Ö£o
www.openedv.com
//ìÔ±|μêÆì£o
http://eboard.taobao.com
//1ãÖYêDDÇòíμç×ó¿Æ¼¼óDÏT1«Ë¾
//×÷ÕߣoÕyμãÔ-×ó @ALIENTEK
int main(void)
{
u16 adcx;
float temp;
u8 t=0;
u16 dacval=0;
u8 key;
NVIC_PriorityGroupConfig(NVIC_PriorityGroup_2);//éèÖÃÏμí3ÖD¶ÏóÅÏ輶·Ö×é2
delay_init(168); //3õê¼»ˉÑóê±oˉêy
uart_init(115200); //3õê¼»ˉ′®¿ú2¨ìØÂêÎa115200
LED_Init(); //3õê¼»ˉLED
LCD_Init(); //LCD3õê¼»ˉ
Adc_Init(); //adc3õê¼»ˉ
KEY_Init(); //°′¼ü3õê¼»ˉ
Dac1_Init(); //DACí¨μà13õê¼»ˉ
POINT_COLOR=RED;
LCD_ShowString(30,50,200,16,16,"Explorer STM32F4");
LCD_ShowString(30,70,200,16,16,"DAC TEST");
LCD_ShowString(30,90,200,16,16,"ATOM@ALIENTEK");
LCD_ShowString(30,110,200,16,16,"2014/5/6");
LCD_ShowString(30,130,200,16,16,"WK_UP:+ KEY1:-");
POINT_COLOR=BLUE;//éèÖÃ×ÖìåÎaà¶é«
LCD_ShowString(30,150,200,16,16,"DAC VAL:");
LCD_ShowString(30,170,200,16,16,"DAC VOL:0.000V");
LCD_ShowString(30,190,200,16,16,"ADC VOL:0.000V");
Dac1_Set_Vol(3300);
// DAC_SetChannel1Data(DAC_Align_12b_R,2500);//3õê¼ÖμÎa0
// while(1)
// {
// t++;
// key=KEY_Scan(0);
// if(key==WKUP_PRES)
// {
// if(dacval<4000)dacval+=200;
// DAC_SetChannel1Data(DAC_Align_12b_R, dacval);//éèÖÃDACÖμ
// }else if(key==2)
// {
// if(dacval>200)dacval-=200;
// else dacval=0;
// DAC_SetChannel1Data(DAC_Align_12b_R, dacval);//éèÖÃDACÖμ
// }
// if(t==10||key==KEY1_PRES||key==WKUP_PRES) //WKUP/KEY1°′ÏÂáË,»òÕ߶¨ê±ê±¼äμ½áË
// {
// adcx=DAC_GetDataOutputValue(DAC_Channel_1);//¶áè¡Ç°ÃæéèÖÃDACμÄÖμ
// LCD_ShowxNum(94,150,adcx,4,16,0); //ÏÔê¾DAC¼Ä′æÆ÷Öμ
// temp=(float)adcx*(3.3/4096); //μÃμ½DACμçÑ1Öμ
// adcx=temp;
// LCD_ShowxNum(94,170,temp,1,16,0); //ÏÔê¾μçÑ1ÖμÕûêy2¿·Ö
// temp-=adcx;
// temp*=1000;
// LCD_ShowxNum(110,170,temp,3,16,0X80); //ÏÔê¾μçÑ1ÖμμÄD¡êy2¿·Ö
// adcx=Get_Adc_Average(ADC_Channel_5,10); //μÃμ½ADC×a»»Öμ
// temp=(float)adcx*(3.3/4096); //μÃμ½ADCμçÑ1Öμ
// adcx=temp;
// LCD_ShowxNum(94,190,temp,1,16,0); //ÏÔê¾μçÑ1ÖμÕûêy2¿·Ö
// temp-=adcx;
// temp*=1000;
// LCD_ShowxNum(110,190,temp,3,16,0X80); //ÏÔê¾μçÑ1ÖμμÄD¡êy2¿·Ö
// LED0=!LED0;
// t=0;
// }
// delay_ms(10);
// }
}
[/mw_shl_code]
DAC实验:用USMART在串口调试助手中输入的Dac1_Set_Vol()值与LCD上DAC VAL的显示值存在偏差 这是什么原因?
不知道你说的软硬件条件是什么样,
目测是用DA输出,然后再AD采集?
如果是,有偏差就很正常,关键是差多差少的问题。
一周热门 更多>