信号发生器的制作基于AD9850
电压值:1.6V
频率:300Hz

image.png


信号发生器

image.png

10100HZ

单片机源程序
/*******************************************************
  • 项目名:基于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;
  • 复制代码