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

📄 main._c

📁 AVR单片机用C语言编写的包括时钟
💻 _C
字号:
#include "iom64v.h"
#include "main.h"
void Init_System(void)
{
  uchar i;
  
  
  SREG=0x80;
  
  DDRC=0x0f;
  PORTC=0xf0;
  
  DDRB=0xFF;
  PORTB =0xff;
   
  DDRE=0xff;
  PORTE=0xff;
  
  for(i=0;i<50;i++)
  syst_parm[i]=0;
 //SysPTosyst();
  MFlage=0;
 TFlage=0;
 AutPrintC=0;
 AutCompC=0;
 SelfCheck=0;//自较
 MarkOk=0;
 Counter1=0; 
 Counter2=0;
 Counter=0;
 
 TbSample=0;
 Init_Usart(); 
 Init_Timer();
 Int_Show();
 Init_TWI();
}
void Int_Show(void)
{
 uchar  InShow[6]={0x0c,0x0c,0x0c,0x0c,0x0c,0x0c};//0x14 H
 
  wdm164(InShow);
  
}
void main(void)
{
 uchar ShowBu1[25],ShowBu2[15];
 uchar i,key; 
 float ReturnValue;
 SP=0x10ff;
WDTCR = (1<<WDCE) | (1<<WDE);
WDTCR = 0x00;
 Init_System();
 ShowBu1[0]=0x00;
 
//while(1)
//{
// key=KeyProc();
//} 
 for(i=1;i<25;i++)
 ShowBu1[i]=0;
 //IntSysP();
 //SetTime();
 //ReadTime(ShowBu1);
 //ReadTime(ShowBu1);
 SysPTosyst();
 TCCR1B=0xc6;
 DDRE=0xff;
 while(1)
{
 
 PORTE=PORTE & 0xef;
 PORTE=PORTE | 0x80;
 PORTE=(PORTE & 0xfb)|0x08;
 TbSample=1;
 MarkOk=0;
 while(MarkOk!=1);
 TbSample=10;
 
 for(i=0;i<6;i++)
 ShowBu2[i]=11;
 wdm164(ShowBu2);
 i=0;
  
 while(i==0)
 {
  if(TbSample==0)
  {
   PORTE=(((PORTE|0x10)|0x20)& 0x7f);//hd=1;h=1;z=0
   TbSample=0;
   
   jiaozheng();
   
   PORTB=(PORTB | 0x0f)& 0xff; 
  } 
 if(GHj==1) 
 {
  PORTE=PORTE|0x80;
  PORTE=(PORTE & 0xf7)|0x04;
  TbSample=6;
 
  PORTB=(PORTB | 0x0f)& 0xfb; 
  while(TbSample!=8);
 
  PORTB=(PORTB | 0x0f)& 0xff; 
  if((Comunpter())<(syst_parm[15]-0.5))
  {
  
   PORTE=(((PORTE|0x10)&0xdf)& 0x7f);//hd=0;h=1;z=0
   TbSample=0;
   
   jiaozheng();
   
   PORTB=(PORTB | 0x0f)& 0xff; 
   
  }
  GHj=3;
  TbSample=10;
 PORTE=PORTE|0x80; //z=1;
 }  
 key=KeyProc();
 if(key==13 && GHj==3)
 {
  GHj=0;
  i=1;
 }
 if(key==3 )
 {
  TbSample=0;
  GHj=1;
 }

}
 AutPrintC=0;
 AutCompC=0;
 Counter2=0;
 FloatToUchar(42,ShowBu1);
 FloatToUchar(43,ShowBu2);
 ShowBu2[0]=ShowBu1[5];
 ShowBu2[1]=ShowBu1[4];
 ShowBu2[2]=ShowBu1[3];
 ShowBu1[5]=ShowBu2[3];
 ShowBu2[3]=ShowBu2[5];
 ShowBu2[5]=ShowBu1[5];
 wdm164(ShowBu2);
while(i==1)
{

   if((Counter2/30)>=1)
  {
    PORTE=(PORTE & 0xf7)|0x04;
    TbSample=6;
    Counter2=0; 
  }
  
  if(TbSample==8)
  {
   TbSample=10;
    ReturnValue=Comunpter();
    FloatToUchar(42,ShowBu1);
    FloatToUchar(43,ShowBu2);
	ShowBu2[0]=ShowBu1[5];
    ShowBu2[1]=ShowBu1[4];
    ShowBu2[2]=ShowBu1[3];
    ShowBu1[5]=ShowBu2[3];
    ShowBu2[3]=ShowBu2[5];
    ShowBu2[5]=ShowBu1[5];
    wdm164(ShowBu2);
   if(ReturnValue>=syst_parm[10] || ReturnValue<=syst_parm[11])
   {
     PrintByte(0x4a);
     PrintByte(0x0a);
   }
   if((ReturnValue<=syst_parm[15]-0.5)&& (PORTE& 0x20 ==0x10))
   {
   //goto loop; 
   PORTE=(((PORTE|0x10)&0xdf)& 0x7f);//hd=0;h=1;z=0
   TbSample=0;
   jiaozheng();
   }
  if((ReturnValue>=syst_parm[15])&& (PORTE& 0x20 ==0x00))
  {
    PORTE=(((PORTE|0x10)|0x20)& 0x7f);//hd=1;h=1;z=0
	TbSample=0;
    jiaozheng();
   //goto loop;
   
  }
 }
 
  if((AutCompC/60)>=syst_parm[13])
  {
   TbSample=0;
   jiaozheng();
   PORTB=(PORTB | 0x0f)& 0xff; 
   AutCompC=0;
  } 
  
  if(keypressed())
 {
  if(keyscan()==13)
  {
   i=0;
   break;
  } 
 } 
  if((AutPrintC/60)>=syst_parm[14])
  {
    AutPrintC=0;
    print(1);
  }
 } 
}
}

⌨️ 快捷键说明

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