D题-报告5-程序清单 | ||||
| ||||
D题-报告5-程序清单 程序清单: //stm32开发板源程序#include "DAC7611.h" #include "delay.h" #include "key.h" #include "sys.h" #include "lcd.h" #include "usart.h" #include "usmart.h"
int main(void) { u8 key; u16 adcx; float temp; u8 t=0; u16 dacval=0;
delay_init(); NVIC_PriorityGroupConfig(NVIC_PriorityGroup_2); uart_init(115200); KEY_Init(); LCD_Init(); usmart_dev.init(72); DAC7611_Init(); LCD_Fill(0,0,240,320,WHITE); POINT_COLOR=BLUE; while(1) { LCD_ShowString(60,90,200,16,16," Signal Group "); LCD_ShowString(60,110,200,16,16," 212EDA@Ujs "); LCD_ShowString(60,130,200,16,16," 2015/8 "); key=KEY_Scan(0); if(key == KEY0_PRES||key == KEY1_PRES||key == KEY2_PRES||key == KEY3_PRES||key == KEY4_PRES) break; }
LCD_Clear(WHITE); POINT_COLOR=GREEN;
LCD_ShowString(60,90,200,16,16," DAC TEST ");
POINT_COLOR=BLUE; // LCD_ShowString(60,150,200,16,16,"DAC VAL:"); LCD_ShowString(60,170,200,16,16,"DAC VOL:0.000V"); DAC7611_Cnv(dacval); while(1) { t++; key=KEY_Scan(0); if(key==KEY0_PRES) { if(dacval<4096) dacval+=10; else dacval=0; }
else if(key==KEY1_PRES) { if(dacval>10) dacval-=10; else dacval=4096; } else if(key==KEY2_PRES) { if(dacval<4096) dacval+=200; else dacval=0; } else if(key==KEY3_PRES) { if(dacval>200) dacval-=200; else dacval=4096; } else if(key==KEY4_PRES) { dacval=0; } DAC7611_Cnv(dacval); if(t==10) { adcx=dacval; temp=(float)adcx*(4.096/4096); adcx=temp; LCD_ShowxNum(124,170,temp,1,16,0); temp-=adcx; temp*=1000; LCD_ShowxNum(140,170,temp,3,16,0X80); t=0; } delay_ms(10);
} }
|