信號發生器的制作基于AD9850
IMG0692A.jpg (21.82 KB, 下載次數: 235)
下載附件
2017-8-28 20:27 上傳
IMG0693A.jpg (22.21 KB, 下載次數: 212)
下載附件
2017-8-28 20:27 上傳
IMG0694A.jpg (21.23 KB, 下載次數: 212)
下載附件
2017-8-28 20:27 上傳
0.png (63.11 KB, 下載次數: 206)
下載附件
2017-8-28 20:31 上傳
0.png (44.94 KB, 下載次數: 226)
下載附件
2017-8-28 20:31 上傳
所有資料51hei提供下載:
[電子設計]函數信號發生器(全套).rar
(469.29 KB, 下載次數: 359)
2017-8-28 19:46 上傳
點擊文件名下載附件
下載積分: 黑幣 -5
單片機源程序如下:
- /*******************************************************
- 項目名:基于ARM Cortex-M3 函數信號發生器
- 涉及便件連接情況: PA0~7--------DDS模塊 D0~D7
- PB4 PB5 PB6----DDS模塊fqud reset w_clk
- PB0 PB2 PB3----液晶12864 CS(RS) DIO(RW) CLK(EP)
- PE0 PE1 PE2 ----KEY3 KEY4 KEY5
- PD1 PG5------KEY1 KEY2
- PD0 PG2------LED1 LED2
- PF0 PF1-----接24C04 SDA SCL
- 程序主要功能:
- 作者:suqingxiao huangrenji liangping
- *********************************************************/
- #include <includes.h>
- #include "AD9850.h"
- #include "24C04.h"
- #define SysCtlPeriEnable SysCtlPeripheralEnable
- #define SysCtlPeriDisable SysCtlPeripheralDisable
- #define GPIOPinTypeOut GPIOPinTypeGPIOOutput
- #define TASK_STK_SIZE 64
- /**************************************
- CONSTANTS 常量
- **************************************/
- /************************************
- VARIABLES 變量
- *************************************/
- uint16 now_color=0; //當前色
- uint16 state=0,flag=0; //狀態
- uint16 frist_in=0; //初次進入標志
- unsigned long num,aa=1,temp=0;
- unsigned long ulData = 0;
- unsigned char buff[5];
- unsigned char display[10];
- unsigned char fshi1=0,fge1=0,temp1=0;
- unsigned char fshi2=0,fge2=0,temp2=0;
- unsigned char fshi3=0,fge3=0,temp3=0;
- unsigned long dat=0,dat2,dat3;
- unsigned char wan=0, qian=0,ge=0,shi=0,bai=0;
- unsigned char wan2, qian2,ge2,shi2,bai2;
- unsigned char wan3, qian3,ge3,shi3,bai3;
- unsigned char ge4,shi4;
- static OS_STK GstkStart[TASK_START_STK_SIZE];//啟動任務的堆棧
- static OS_STK GstkLED[TASK_LED_STK_SIZE];
- OS_STK Task1Stk[TASK_STK_SIZE];
- OS_STK Task2Stk[TASK_STK_SIZE];
- /*************************************
- FUNCTION PROTOTYPES 函數聲明
- **************************************/
- static void taskStart (void *parg); //啟動任務
- static void taskLED(void *parg); //任務0
- void Task1(void *data);
- void Task2(void *data);
- /***********************************************
- 功能:主程序
- ************************************************/
- int main (void)
- {
- OSInit(); // OS-II 初始化uC/OS-II的內核
- OSTaskCreate( taskStart,
- (void *)0,
- &GstkStart[TASK_START_STK_SIZE-1],
- TASK_START_PRIO );
- /* 初始化啟動任務 */
- OSStart(); // 啟動uC/OS-II*/
- return(0);
- }
- /****************************************
- ** Function name: Task_Start
- ** input parameters: *p_arg
- *****************************************/
- static void taskStart (void *parg)
- {
- (void)parg;
- targetInit(); // 初始化目標單片機
- #if OS_TASK_STAT_EN > 0
- OSStatInit(); // 使能統計功能
- #endif
-
- /* 在這里創建其他任務 */
- OSTaskCreate( taskLED,
- (void *)0,
- &GstkLED[TASK_LED_STK_SIZE-1],
- TASK_LED_PRIO ); // 建處理任務
- OSTaskCreate(Task1, (void *)2, &Task1Stk[TASK_STK_SIZE - 1],2);
- OSTaskCreate(Task2, (void *)3, &Task2Stk[TASK_STK_SIZE - 1], 3);
-
-
- KEY_Init(KEY1 | KEY2 | KEY3 |KEY4 |KEY5 ); //按鍵初始化
-
- LCDInit(); //LCD12864初始化 // LCD初始化
- clear_all(); // 清屏
-
- while (1)
- {
- /* 啟動任務可在這里掛起 */
- OSTaskSuspend(OS_PRIO_SELF);
- }
- }
- /***********************************************
- 名稱:任務0
- 功能:
- **********************************************/
- static void taskLED(void *parg)
- {
- (void)parg;
- Display(ulData);//開機顯示
- SystemInit();// 系統初始化
- init();//24C04初始化
- num=read_add(1);//選波型,讀波型
-
- /******正弦波****/
- shi=read_add(2);//讀24C04中正弦波十位
- bai=read_add(3);//讀24C04中正弦波百位
- //qian=read_add(6);
- //wan=read_add(5);
- dat=read_add(6);////讀24C04中正弦波頻率
- dat=wan*10000+qian*1000+bai*100+shi*10;//讀24C04中正弦波頻率
-
- fge1=read_add(7);//讀24C04中正弦波幅度小數位
- fshi1=read_add(8);
- temp1=read_add(9);//讀24C04中正弦波幅度值
- temp1=fshi1*10+fge1;//讀24C04中正弦波幅度值
- /*************/
-
- /*****方波****/
- shi2=read_add(10);//讀24C04中方波十位
- bai2=read_add(11);//讀24C04中方波百位
- //qian=read_add(6);
- //wan=read_add(5);
- dat2=read_add(12);//讀24C04中方波頻率
- dat2=wan2*10000+qian2*1000+bai2*100+shi2*10;
-
- fge2=read_add(13);//讀24C04中方波幅度小數位
- fshi2=read_add(14);
-
- temp2=read_add(15);//讀24C04中方波幅度
- temp2=fshi2*10+fge2;//讀24C04中方波幅度
- /*************/
-
- /*****三角波*****/
- shi3=read_add(16);//讀24C04中三角波十位
- bai3=read_add(17);//讀24C04中三角波百位
- //qian=read_add(6);
- //wan=read_add(5);
- dat3=read_add(18);//讀24C04中三角波*頻率
- dat3=wan3*10000+qian3*1000+bai3*100+shi3*10;
-
- fge3=read_add(19);//讀24C04中三角波幅度小數位
- fshi3=read_add(20);
- temp3=read_add(21);//讀24C04中三角波幅度值
- temp3=fshi3*10+fge3;//讀24C04中三角波幅度值
- /*************/
- //num=temp;
- for(;;)
- {
-
- if(flag==1)//標志位為1時可以操作24C04
- {
- flag=0;//標志位清0
- write_add(1,num);//選波型 寫到24C04
-
- /******正弦波*******/
- write_add(2,shi);//寫正弦波頻率的十位到24C04
- write_add(3,bai);//寫正弦波頻率的百位到24C04
- // write_add(6,qian);
- //write_add(5,wan);
- dat=wan*10000+qian*1000+bai*100+shi*10;
- write_add(6,dat);//寫正弦波頻率值到24C04
-
- write_add(7,fge1);//寫正弦波幅值的小數位到24C04
- write_add(8,fshi1);
- temp1=fshi1*10+fge1;//寫正弦波幅值到24C04
- write_add(9,temp1);
- /************/
-
- /***方波*****/
- write_add(10,shi2);//寫方波頻率的十位到24C04
- write_add(11,bai2);//寫方波頻率的百位到24C04
- // write_add(6,qian);
- //write_add(5,wan);
- dat2=wan2*10000+qian2*1000+bai2*100+shi2*10;
- write_add(12,dat2);//寫方波頻率值到24C04
-
- write_add(13,fge2);
- write_add(14,fshi2);
- temp2=fshi2*10+fge2;
- write_add(15,temp2);
- /******************/
-
- /******三角波*******/
- write_add(16,shi3);//寫三角波頻率的十位到24C04
- write_add(17,bai3);//寫三角波頻率的百位到24C04
- // write_add(6,qian);
- //write_add(5,wan);
- dat3=wan3*10000+qian3*1000+bai3*100+shi3*10;
- write_add(18,dat3);//寫三角波頻率值到24C04
-
- write_add(19,fge3);//寫三角波幅值的小數位到24C04
- write_add(20,fshi3);
- temp3=fshi3*10+fge3;
- write_add(21,temp3);//寫三角波頻率值到24C04
- /*****************/
- }
-
- if(KEY_Get(KEY1))//KEY1選波形型號
- {
- OSTimeDlyHMSM(0,0,0,100); //延時消抖
- if(KEY_Get(KEY1))//再判斷KEY1是否被按下
- {
-
- num++;//選波形型號
- flag=1;
- if(num==4)
- {
- num=0;
- }
- }
- }
-
- if(num==1)////正弦波
- {
-
- LCD_ComdWrite(0x93);//正弦波顯示的位置
- LCD_ComdWrite(0x0C);//關光標
- Displaysin();//正弦波
- dat=wan*10000+qian*1000+bai*100+shi*10;//顯示初始值
-
- Write_9850(dat); //控制DDS模塊輸出
- display[4]=dat%100000/10000+0X30;//萬位
- display[3]=dat%10000/1000+0X30;//千位
- display[2]=dat%1000/100+0X30;//百位
- display[1]=dat%100/10+0X30;//十位
- display[0]=dat%10+0X30;//個位
- if(display[4]==0x30)//高位為0,不顯示
- {
- display[4]=0x20;
- if(display[3]==0x30) //高位為0,不顯示
- {
- display[3]=0x20;
- if(display[2]==0x30)//次高位為0,不顯示
- {
- display[2]=0x20;
- if(display[1]==0x30)
- display[1]=0x20;
- }
- }
- }
- flag=1;
- LCD_ComdWrite(0x9B);//頻率顯示的位置
- LCD_DataWrite(display[4]);//顯示萬位
- LCD_DataWrite(display[3]);//顯示百位
- LCD_DataWrite(display[2]);//顯示十位
- LCD_DataWrite(display[1]);//顯示十位
- LCD_DataWrite(display[0]);//顯示個位
- LCD_DataWrite('H');
- LCD_DataWrite('Z');
- if(KEY_Get(KEY2))//KEY2控制加頻率
- {
- OSTimeDlyHMSM(0,0,0,100);
- if(KEY_Get(KEY2))
- {
- //LCD_ComdWrite(0x9c);
- //LCD_ComdWrite(0x0F);//開光標顯示
- //LCD_DataWrite(aa+0x30);
- shi++;
- flag=1;
- if(shi==10)
- {
- shi=0;
- bai++;
- flag=1;
- if(bai==10)
- {
- bai=0;
- qian++;
- flag=1;
- if(qian==10)
- {
- qian=0;
- wan++;
- flag=1;
- if(wan==10)
- {
- wan=0;
-
- }
-
- dat=wan*10000+qian*1000+bai*100+shi*10;
- Write_9850(dat); //控制DDS模塊輸出
- }
-
- dat=wan*10000+qian*1000+bai*100+shi*10;
- Write_9850(dat); //控制DDS模塊輸出
- }
-
- dat=wan*10000+qian*1000+bai*100+shi*10;
- Write_9850(dat);//控制DDS模塊輸出
- }
-
- dat=wan*10000+qian*1000+bai*100+shi*10;
- Write_9850(dat); //控制DDS模塊輸出
-
- }
- }
-
- if(KEY_Get(KEY3))//KEY3控制減頻率
- {
- OSTimeDlyHMSM(0,0,0,100);
- if(KEY_Get(KEY3))
- {
- //LCD_ComdWrite(0x9c);
- //LCD_ComdWrite(0x0F);//開光標顯示
- //LCD_DataWrite(aa+0x30);
- shi--;
- flag=1;
- if(shi==0)
- {
- shi=10;
- bai--;
- flag=1;
- if(bai==0)
- {
- bai=10;
- qian--;
- //flag=1;
- if(qian==0)
- {
- qian=10;
- wan--;
- //flag=1;
- if(wan==0)
- {
- wan=0;
- }
-
- dat=wan*10000+qian*1000+bai*100+shi*10;
- Write_9850(dat); //控制DDS模塊輸出
- }
-
- dat=wan*10000+qian*1000+bai*100+shi*10;
- Write_9850(dat); //控制DDS模塊輸出
- }
-
- dat=wan*10000+qian*1000+bai*100+shi*10;
- Write_9850(dat);//控制DDS模塊輸出
- }
-
- dat=wan*10000+qian*1000+bai*100+shi*10;
- Write_9850(dat); //控制DDS模塊輸出
-
- }
- display[4]=dat%100000/10000+0X30;//顯示千位
- display[3]=dat%10000/1000+0X30;//顯示千位
- display[2]=dat%1000/100+0X30;//顯示百位
- display[1]=dat%100/10+0X30;//顯示十位
- display[0]=dat%10+0X30;//顯示個位
- if(display[4]==0x30)
- {
- display[4]=0x20;
- if(display[3]==0x30) //高位為0,不顯示
- {
- display[3]=0x20;
- if(display[2]==0x30)//次高位為0,不顯示
- {
- display[2]=0x20;
- if(display[1]==0x30)
- display[1]=0x20;
- }
- }
- }
- LCD_ComdWrite(0x9B);//頻率顯示的位置
- LCD_DataWrite(display[4]);
- LCD_DataWrite(display[3]);
- LCD_DataWrite(display[2]);
- LCD_DataWrite(display[1]);
- LCD_DataWrite(display[0]);
- LCD_DataWrite('H');
- LCD_DataWrite('Z');
- }
- }////正弦波
-
-
- if(num==2)// 顯示方波
- {
- flag=1;
- LCD_ComdWrite(0x93);//方波顯示的位置
- LCD_ComdWrite(0x0C);//關光標
- Displayfang();// 顯示方波
- dat2=wan2*10000+qian2*1000+bai2*100+shi2*10;
- Write_9850(dat2); //控制DDS模塊輸出
- display[4]=dat2%100000/10000+0X30;//顯示千位
- display[3]=dat2%10000/1000+0X30;//顯示千位
- display[2]=dat2%1000/100+0X30;//顯示百位
- display[1]=dat2%100/10+0X30;//顯示十位
- display[0]=dat2%10+0X30;//顯示個位
- if(display[4]==0x30)
- {
- display[4]=0x20;
- if(display[3]==0x30) //高位為0,不顯示
- {
- display[3]=0x20;
- if(display[2]==0x30)//次高位為0,不顯示
- {
- display[2]=0x20;
- if(display[1]==0x30)
- display[1]=0x20;
- }
- }
- }
- LCD_ComdWrite(0x9B);//頻率顯示的位置
- LCD_DataWrite(display[4]);
- LCD_DataWrite(display[3]);
- LCD_DataWrite(display[2]);
- LCD_DataWrite(display[1]);
- LCD_DataWrite(display[0]);
- LCD_DataWrite('H');
- LCD_DataWrite('Z');
- if(KEY_Get(KEY2))//KEY2控制加頻率
- {
- OSTimeDlyHMSM(0,0,0,100);
- if(KEY_Get(KEY2))
- {
- //LCD_ComdWrite(0x9c);
- //LCD_ComdWrite(0x0F);//開光標顯示
- //LCD_DataWrite(aa+0x30);
- shi2++;
- flag=1;
- if(shi2==10)
- {
- //aa=1;
- shi2=0;
- bai2++;
- flag=1;
- if(bai2==10)
- {
- bai2=0;
- qian2++;
-
- if(qian2==10)
- {
- qian2=0;
- wan2++;
- if(wan2==10)
- {
- wan2=0;
- }
-
- dat2=wan2*10000+qian2*1000+bai2*100+shi2*10;
- Write_9850(dat2); //控制DDS模塊輸出
- }
-
- dat2=wan2*10000+qian2*1000+bai2*100+shi2*10;
- Write_9850(dat2); //控制DDS模塊輸出
- }
-
- dat2=wan2*10000+qian2*1000+bai2*100+shi2*10;
- Write_9850(dat2);//控制DDS模塊輸出
- }
-
- dat2=wan2*10000+qian2*1000+bai2*100+shi2*10;
- Write_9850(dat2); //控制DDS模塊輸出
-
- }
- }
-
-
- if(KEY_Get(KEY3))//KEY3控制減頻率
- {
- OSTimeDlyHMSM(0,0,0,100);
- if(KEY_Get(KEY3))
- {
- //LCD_ComdWrite(0x9c);
- //LCD_ComdWrite(0x0F);//開光標顯示
- //LCD_DataWrite(aa+0x30);
- shi2--;
- flag=1;
- if(shi2==0)
- {
- //aa=1;
- shi2=10;
- bai2--;
- flag=1;
- if(bai2==0)
- {
- bai2=10;
- qian2--;
- if(qian2==0)
- {
- qian2=10;
- wan2--;
- if(wan2==0)
- {
- wan2=0;
- }
- dat2=wan2*10000+qian2*1000+bai2*100+shi2*10;
- Write_9850(dat2); //控制DDS模塊輸出
- }
- dat2=wan2*10000+qian2*1000+bai2*100+shi2*10;
- Write_9850(dat2); //控制DDS模塊輸出
- }
- dat2=wan2*10000+qian2*1000+bai2*100+shi2*10;
- Write_9850(dat2);//控制DDS模塊輸出
- }
-
- dat2=wan2*10000+qian2*1000+bai2*100+shi2*10;
- Write_9850(dat2); //控制DDS模塊輸出
- }
- display[4]=dat2%100000/10000+0X30;//顯示千位
- display[3]=dat2%10000/1000+0X30;//顯示千位
- display[2]=dat2%1000/100+0X30;//顯示百位
- display[1]=dat2%100/10+0X30;//顯示十位
- display[0]=dat2%10+0X30;//顯示個位
- if(display[4]==0x30)
- {
- display[4]=0x20;
- if(display[3]==0x30) //高位為0,不顯示
- {
- display[3]=0x20;
- if(display[2]==0x30)//次高位為0,不顯示
- {
- display[2]=0x20;
- if(display[1]==0x30)
- display[1]=0x20;
- }
- }
- }
- LCD_ComdWrite(0x9B);//頻率顯示的位置
- LCD_DataWrite(display[4]);
- LCD_DataWrite(display[3]);
- LCD_DataWrite(display[2]);
- LCD_DataWrite(display[1]);
- LCD_DataWrite(display[0]);
- LCD_DataWrite('H');
- LCD_DataWrite('Z');
- }
- }// 顯示方波
-
-
-
- if(num==3)// 顯示三角波
- {
- LCD_ComdWrite(0x93);//"三角波"顯示的位置
- LCD_ComdWrite(0x0C);//關光標
- Displaythree();// 顯示"三角波"
- dat3=wan3*10000+qian3*1000+bai3*100+shi3*10;
- Write_9850(dat3);//控制DDS模塊輸出
- display[4]=dat3%100000/10000+0X30;//顯示千位
- display[3]=dat3%10000/1000+0X30;//顯示千位
- display[2]=dat3%1000/100+0X30;//顯示百位
- display[1]=dat3%100/10+0X30;//顯示十位
- display[0]=dat3%10+0X30;//顯示個位
- if(display[4]==0x30)
- {
- display[4]=0x20;//高位為0,不顯示
- if(display[3]==0x30) //高位為0,不顯示
- {
- display[3]=0x20;
- if(display[2]==0x30)//次高位為0,不顯示
- {
- display[2]=0x20;
- if(display[1]==0x30)
- display[1]=0x20;
- }
- }
- }
- LCD_ComdWrite(0x9B);//頻率顯示的位置
- LCD_DataWrite(display[4]);
- LCD_DataWrite(display[3]);
- LCD_DataWrite(display[2]);
- LCD_DataWrite(display[1]);
- LCD_DataWrite(display[0]);
- LCD_DataWrite('H');
- LCD_DataWrite('Z');
- if(KEY_Get(KEY2))//KEY2控制加頻率
- {
- OSTimeDlyHMSM(0,0,0,100);
- if(KEY_Get(KEY2))
- {
- //LCD_ComdWrite(0x9c);
- //LCD_ComdWrite(0x0F);//開光標顯示
- //LCD_DataWrite(aa+0x30);
- shi3++;
- flag=1;
- if(shi3==10)
- {
- shi3=0;
- bai3++;
- flag=1;
- if(bai3==10)
- {
- bai3=0;
- qian3++;
- if(qian3==10)
- {
- qian3=0;
- wan3++;
- if(wan3==10)
- {
- wan3=0;
- }
- dat3=wan3*10000+qian3*1000+bai3*100+shi3*10;
- Write_9850(dat3); //控制DDS模塊輸出
- }
- dat3=wan3*10000+qian3*1000+bai3*100+shi3*10;
- Write_9850(dat3); //控制DDS模塊輸出
- }
- dat3=wan3*10000+qian3*1000+bai3*100+shi3*10;
- Write_9850(dat3);//控制DDS模塊輸出
- }
-
- dat3=wan3*10000+qian3*1000+bai3*100+shi3*10;
- Write_9850(dat3); //控制DDS模塊輸出
-
- }
- }
-
- if(KEY_Get(KEY3))//KEY3控制減頻率
- {
- OSTimeDlyHMSM(0,0,0,100);
- if(KEY_Get(KEY3))
- {
- //LCD_ComdWrite(0x9c);
- //LCD_ComdWrite(0x0F);//開光標顯示
- //LCD_DataWrite(aa+0x30);
- shi3--;
- flag=1;
- if(shi3==0)
- {
- //aa=1;
- shi3=10;
- bai3--;
- flag=1;
- if(bai3==0)
- {
- bai3=10;
- qian3--;
- if(qian3==0)
- {
- qian3=10;
- wan2--;
- if(wan3==0)
- {
- wan3=0;
- }
- dat3=wan3*10000+qian3*1000+bai3*100+shi3*10;
- Write_9850(dat3);//控制DDS模塊輸出
- }
- dat3=wan3*10000+qian3*1000+bai3*100+shi3*10;
- Write_9850(dat3); //控制DDS模塊輸出
- }
- dat3=wan3*10000+qian3*1000+bai3*100+shi3*10;
- Write_9850(dat3);//控制DDS模塊輸出
- }
-
- dat3=wan2*10000+qian3*1000+bai3*100+shi3*10;
- Write_9850(dat3); //控制DDS模塊輸出
- }
- display[4]=dat3%100000/10000+0X30;//顯示千位
- display[3]=dat3%10000/1000+0X30;//顯示千位
- display[2]=dat3%1000/100+0X30;//顯示百位
- display[1]=dat3%100/10+0X30;//顯示十位
- display[0]=dat3%10+0X30;//顯示個位
- if(display[4]==0x30)
- {
- display[4]=0x20;
- if(display[3]==0x30) //高位為0,不顯示
- {
- display[3]=0x20;
- if(display[2]==0x30)//次高位為0,不顯示
- {
- display[2]=0x20;
- if(display[1]==0x30)
- display[1]=0x20;
- }
- }
- }
- LCD_ComdWrite(0x9B);//頻率顯示的位置
- LCD_DataWrite(display[4]);
- LCD_DataWrite(display[3]);
- LCD_DataWrite(display[2]);
- LCD_DataWrite(display[1]);
- LCD_DataWrite(display[0]);
- LCD_DataWrite('H');
- LCD_DataWrite('Z');
- }
- } // 顯示三角波
-
-
- if(num==1)//按鍵調幅(正弦波)
- {
- temp1=fshi1*10+fge1;
- buff[0]=temp1/10+0x30;
- buff[1]=temp1%10+0x30;
- LCD_ComdWrite(0x8B);
- LCD_DataWrite(buff[0]);
- LCD_DataWrite('.');
- LCD_DataWrite(buff[1]);
- LCD_DataWrite('V');
- if(KEY_Get(KEY4))//KEY4控制加幅度
- {
- OSTimeDlyHMSM(0,0,0,100);
- flag=1;
- if(KEY_Get(KEY4))
- {
- fge1++;
- flag=1;
- if(fge1==10)
- {
- fge1=0;
- fshi1++;
- flag=1;
- if(fshi1==6)
- {
- fshi1=0;
- }
- temp1=fshi1*10+fge1;
- }
-
- temp1=fshi1*10+fge1;
- buff[0]=temp1/10+0x30;
- buff[1]=temp1%10+0x30;
- LCD_ComdWrite(0x8B);
- LCD_DataWrite(buff[0]);
- LCD_DataWrite('.');
- LCD_DataWrite(buff[1]);
- LCD_DataWrite('V');
- }
- }
-
- if(KEY_Get(KEY5))//KEY5控制減幅度
- {
- OSTimeDlyHMSM(0,0,0,100);
- flag=1;
- if(KEY_Get(KEY5))
- {
- fge1--;
- flag=1;
- if(fge1==0)
- {
- fge1=10;
- fshi1--;
- flag=1;
- if(fshi1==0)
- {
- fshi1=0;
- }
- temp1=fshi1*10+fge1;
- }
-
- temp1=fshi1*10+fge1;
- buff[0]=temp1/10+0x30;
- buff[1]=temp1%10+0x30;
- LCD_ComdWrite(0x8B);
- LCD_DataWrite(buff[0]);
- LCD_DataWrite('.');
- LCD_DataWrite(buff[1]);
- LCD_DataWrite('V');
- }
- }
- }//按鍵調幅(正弦波)
-
-
-
- if(num==2)//按鍵調幅(方波)
- {
- temp2=fshi2*10+fge2;
- buff[0]=temp2/10+0x30;
- buff[1]=temp2%10+0x30;
- LCD_ComdWrite(0x8B);
- LCD_DataWrite(buff[0]);
- LCD_DataWrite('.');
- LCD_DataWrite(buff[1]);
- LCD_DataWrite('V');
- if(KEY_Get(KEY4))//KEY4控制加幅度
- {
- OSTimeDlyHMSM(0,0,0,100);
-
- if(KEY_Get(KEY4))
- {
- fge2++;
- flag=2;
- if(fge2==10)
- {
- fge2=0;
- fshi2++;
- flag=1;
- if(fshi2==6)
- {
- fshi2=1;
- }
- temp2=fshi2*10+fge2;
- }
-
- temp2=fshi2*10+fge2;
- buff[0]=temp2/10+0x30;
- buff[1]=temp2%10+0x30;
- LCD_ComdWrite(0x8B);
- LCD_DataWrite(buff[0]);
- LCD_DataWrite('.');
- LCD_DataWrite(buff[1]);
- LCD_DataWrite('V');
- }
- }
-
- if(KEY_Get(KEY5))//KEY5控制減幅度
- {
- OSTimeDlyHMSM(0,0,0,100);
- flag=1;
- if(KEY_Get(KEY5))
- {
- fge2--;
- flag=1;
- if(fge2==0)
- {
- fge2=10;
- fshi2--;
- flag=1;
- if(fshi2==0)
- {
- fshi2=0;
- }
- temp2=fshi2*10+fge2;
- }
-
- temp2=fshi2*10+fge2;
- buff[0]=temp2/10+0x30;
- buff[1]=temp2%10+0x30;
- LCD_ComdWrite(0x8B);
- LCD_DataWrite(buff[0]);
- LCD_DataWrite('.');
- LCD_DataWrite(buff[1]);
- LCD_DataWrite('V');
- }
- }
- }//按鍵調幅(方波)
-
-
- if(num==3)//按鍵調幅(三角波)
- {
-
- temp3=fshi3*10+fge3;
- buff[0]=temp3/10+0x30;
- buff[1]=temp3%10+0x30;
- LCD_ComdWrite(0x8B);
- LCD_DataWrite(buff[0]);
- LCD_DataWrite('.');
- LCD_DataWrite(buff[1]);
- LCD_DataWrite('V');
- if(KEY_Get(KEY4))//KEY4控制加幅度
- {
- OSTimeDlyHMSM(0,0,0,100);
- flag=1;
- if(KEY_Get(KEY4))
- {
- fge3++;
- flag=1;
- ……………………
- …………限于本文篇幅 余下代碼請從51黑下載附件…………
復制代碼
|