⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 main.c

📁 采用AD9851设计的一个产生50M 方波
💻 C
📖 第 1 页 / 共 2 页
字号:
			   }
			if (Key_Code == 0x0E)
			{
			   unsigned char i;
               delay(50);
			  unit(fd1);
                if (f == 0)
				break;
						Fichar = UpDown(Freqdisplay,&f,0);
						if (f<1)
						{
							f = 1;
						}
					//	display(0x80,"       ");
					   freq = f*mul;
					   write_cmd(0x0c);
					   SetFreq(freq,0);
						for (i = Fichar; i>0; i--)
						{
							cnt = Freqdisplay[Fichar-i];
							if (cnt <=9)
								cnt += 0x30;
							else break;
							Dischar[0] = cnt;
							display(0x88-i,Dischar);
						}
                        write_cmd(0x02);
                        for(i=0;i<(p_bit-1);i++)write_cmd(0x14);
						write_cmd(0x0f);
				Key_Code = 0xff;
			}
			if (Key_Code == 0x0C)
			{
			   	p_bit = 0;
                write_cmd(0x0c);
				switch (Fnc)
				{
					case Freq:
						display(0x80,"        ");
						display(0x80,"    1000");
						display(0xc0,"Hz");
						SetFreq(1000,0);
						Key_Push_Flag = FALSE;
						Key_Process = TRUE;					// 置处理标志
						break;
					case FSK:
						display(0x80,"        ");
						display(0xc0,"        ");
						display(0x80,"FSK");
						Key_Push_Flag = FALSE;
						Key_Process = TRUE;					// 置处理标志
						SetFSK(&Key_Push_Flag);
						break;
					case FM:
					    display(0x80,"        ");
						display(0xc0,"        ");
						display(0x80,"FM");
						Key_Push_Flag = FALSE;
						Key_Process = TRUE;
						SetFM(&Key_Push_Flag);
						break;
					case PSK:
						display(0x80,"        ");
					    display(0xc0,"        ");
						display(0x80,"PSK");
						Key_Push_Flag = FALSE;
						Key_Process = TRUE;
						SetPSK(&Key_Push_Flag);
						break;
					case ASK:
						display(0x80,"        ");
					    display(0xc0,"        ");
						display(0x80,"ASK");
						Key_Push_Flag = FALSE;
						Key_Process = TRUE;
						SetASK(&Key_Push_Flag);
						break;
					case AM:
						display(0x80,"        ");
					    display(0xc0,"        ");
						display(0x80,"AM");
						Key_Push_Flag = FALSE;
						Key_Process = TRUE;
//						SetAM(&Key_Push_Flag);
						break;
				}
				Fnc ++;
				Fnc&=0x07;
				En_Key = FALSE;
				Renew_Key = TRUE;
				Key_Code = 0xff;
			}
			  
  }
}
//memdis 指向显示内存区域, ichar 在内存中的位置, ad 显示位置,Key_Code 键入值
/************************************************************************
*作者:    杨乐                                                         *
*函数名:  Dis                                                          *
*功能:    显示处理                                                     *
*入口参数:无                                                           *
*返回值:  无                                                           *
*日期:    2009年1月21日                                                *
************************************************************************/
unsigned long Dis( unsigned char * memdis, unsigned char * ichar, unsigned char ad)
{
	int cnt;
	 unsigned long Data = 0;
 //   p = 0;
//	p_num = 0;
	memdis[*ichar] = Key_Code;
	(*ichar)++;
	if ((*ichar) > 8)
		(*ichar) = 8;
	if (((*ichar) == 1)&&(memdis[0] == 0))
		*ichar = 0;
/*    if(Key_Code == 0x0A)
     {
	   p_num = 7-(*ichar);   
 	   p1 = (*ichar);
	 }*/
	if (*ichar > 0)
	{
		for (i = 0; i < (*ichar); i++)
		{
			Data = Data*10+memdis[i];
		}
       /* for(i = 0; i < p_num; i++)
		{
			Data = Data/10;
		}*/
	}
	else Data = 0;
			
//	display(ad,"        ");
    c1 = (*ichar);
	for (i = (*ichar); i >0; i--)
	{
		cnt = memdis[(*ichar)-i];
		if (cnt <=9)
			cnt += 0x30;
		else break;
		Dischar[0] = cnt;
	//	Dischar[1] = '\0';
		display(ad-i,Dischar);		
	}
	return Data;
}
//
/************************************************************************
*作者:    杨乐                                                         *
*函数名:  UpDown                                                       *
*功能:    增加和减小                                                   *
*入口参数:无                                                           *
*返回值:  无                                                           *
*日期:    2009年1月21日                                                *
************************************************************************/
unsigned char UpDown(unsigned char * memdis,  double * Data, unsigned char updown)
{
	unsigned long tmp1;
	unsigned char cnt;
	display(0x80,"       ");
/*	unsigned char i;
	unsigned long j;
	for(i=0;i<(c1-1);i++)
	c *= 10;
/*	if(p_bit>1)
	{
	 for(i=0;i<(p_bit-1);i++)
	 j *= 10;
	}
	c =c/j;*/
	tmp1 = * Data;

	if (updown == 1)		
		 tmp1 +=c;
	else 
		if ((tmp1>1)&&(tmp1>c)) 
		tmp1 -=c;
	
	* Data = tmp1;
	cnt=0;
	while (tmp1>0)
	{
		tmp1 /= 10;
		cnt++;
	}
	tmp1 = *Data;
	memset(memdis,0,8);

	for (i = 0; i < cnt; i++)
	{
		memdis[cnt-i-1] = tmp1%10;
		tmp1 /= 10;
	}
	return cnt;
}
/************************************************************************
*作者:    杨乐                                                         *
*函数名:  unit                                                         *
*功能:    增加和减小单位换算                                           *
*入口参数无  :                                                         *
*返回值:  无                                                           *
*日期:    2009年1月21日                                                *
************************************************************************/
void unit(unsigned char u)
{
  switch(u)
  {
    case 1:c = 10000000;break;
	case 2:c = 1000000;break;
    case 3:c = 100000;break;
	case 4:c = 10000;break;
	case 5:c = 1000;break;
	case 6:c = 100;break;
	case 7:c = 10;break;
	case 8:c = 1;break;
	default:break;
  }
}
/************************************************************************
*作者:    杨乐                                                         *
*函数名:  num_renew                                                    *
*功能:    光标显示位数据更新                                           *
*入口参数:无                                                           *
*返回值:  无                                                           *
*日期:    2009年1月21日                                                *
************************************************************************/
void num_renew(unsigned char * memdis)
{
  unsigned long fd,i,j,k,cod;
  unsigned long x;
  j = 0;
  unit(p_bit);
  fd = f;
 //  memdis[i-1] = Key_Code;
 /*  if (c1 > 0)
	{
		for (i = 0; i < c1; i++)
		Data = Data*10+memdis[i];       
	}*/
		while (fd>0)
	{
		fd /= 10;
		j++;
	}
	fd = f;
  if((p_bit<=j)&&(Key_Code<10)&&(Key_Code>0))
   { 
     fd /= c;
	while(fd>10)fd %= 10;
     f = (f-fd*c)+(Key_Code*c);
   }
  else if((p_bit>j)&&(Key_Code<10))
    {
	   k = 0;
      	while (fd>0)
	  {
         k++;
        if(k==(9-p_bit))
		{
		  x = fd%10;
		  break;
		}
        else
		fd /= 10;
	  } 
     f = (f-(x*c))+(Key_Code*c);
    } 
 else;
 memset(memdis,0,8);
  fd = f;
   k = 0;
  while (fd>0)
	{
		fd /= 10;
		k++;
	}
 fd = f;
	for (i = 0; i < k; i++)
	{
		memdis[k-i-1] = fd%10;
		fd /= 10;
	}
	display(0x80,"        ");
	for (i = k; i >0; i--)
	{
		cod = memdis[k-i];
		if (cod <=9)
			cod += 0x30;
		else break;
		Dischar[0] = cod;
	//	Dischar[1] = '\0';
		display(0x88-i,Dischar);		
	}
		if (f>72000000)
      {
		freq = 72000000;
	  }
        if (f<1)
		{
		 f = 1;
		}
		 freq = f*mul;
		  SetFreq(freq,0);
}

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -