|
DAC輸出愛(ài)心函數(shù),示波器上可以顯示愛(ài)心函數(shù)
單片機(jī)源程序如下:
- #include "led.h"
- #include "delay.h"
- #include "key.h"
- #include "sys.h"
- #include "lcd.h"
- #include "usart.h"
- #include "dac.h"
- #include "adc.h"
- #include "usmart.h"
- #include "math.h"
- double Fx1,Fx2,Fx3,Fx4,x;
- int main(void)
- {
-
- u16 t=0;
- delay_init(); //延時(shí)函數(shù)初始化
- NVIC_PriorityGroupConfig(NVIC_PriorityGroup_2);//設(shè)置中斷優(yōu)先級(jí)分組為組2:2位搶占優(yōu)先級(jí),2位響應(yīng)優(yōu)先級(jí)
- uart_init(115200); //串口初始化為115200
- KEY_Init(); //初始化按鍵程序
- LED_Init(); //LED端口初始化
- LCD_Init(); //LCD初始化
- usmart_dev.init(72); //初始化USMART
- Adc_Init(); //ADC初始化
- Dac1_Init(); //DAC初始化
- POINT_COLOR=RED;//設(shè)置字體為紅色
- LCD_ShowString(60,50,200,16,16,"WarShip STM32");
- LCD_ShowString(60,70,200,16,16,"DAC TEST");
- LCD_ShowString(60,90,200,16,16,"ATOM@ALIENTEK");
- LCD_ShowString(60,110,200,16,16,"2015/1/15");
- LCD_ShowString(60,130,200,16,16,"WK_UP:+ KEY1:-");
- //顯示提示信息
- POINT_COLOR=BLUE;//設(shè)置字體為藍(lán)色
- LCD_ShowString(60,150,200,16,16,"DAC VAL:");
- LCD_ShowString(60,170,200,16,16,"DAC VOL:0.000V");
- LCD_ShowString(60,190,200,16,16,"ADC VOL:0.000V");
-
- DAC_SetChannel1Data(DAC_Align_12b_R, 0);//初始值為0
- x=1.8165;
- delay_ms(10000);
- delay_ms(10000);
- delay_ms(10000);
- delay_ms(10000);
- delay_ms(10000);
- delay_ms(10000);
- delay_ms(10000);
- while(1)
- {
-
- Fx1=pow(x,0.6666);
- Fx2=sqrt(3.3-pow(x,2));
- Fx3=sin(31.41592*x);
- Fx4=(Fx1+0.9*Fx2*Fx3)*900;
- Dac1_Set_Vol(Fx4+1100);
- if(t==0)
- {
- x=x-0.001;
- }
- else
- {
- x=x+0.001;
- }
- if(x<=0)t=1;
- if(x==1.8165)
- {
- t=0;
- delay_ms(10000);
- }
-
- }
- }
復(fù)制代碼
所有資料51hei提供下載:
愛(ài)心函數(shù).7z
(251.03 KB, 下載次數(shù): 33)
2020-4-27 17:24 上傳
點(diǎn)擊文件名下載附件
愛(ài)心函數(shù)
|
|