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

📄 zi.c

📁 该程序用msp430单片机开发了一款单相电子式多费率电能表
💻 C
字号:

void Pdshduan(void)
{
  unsigned char lastshduan,*gtimep;
  gtimep = gtimer01;
  if((gtimer08[1] != 0) || (gtimer08[2] != 0))
    lastshduan = 8;
  else if((gtimer07[1] != 0) || (gtimer07[2] != 0))
    lastshduan = 7;
  else if((gtimer06[1] != 0) || (gtimer06[2] != 0))
    lastshduan = 6;
  else if((gtimer05[1] != 0) || (gtimer05[2] != 0))
    lastshduan = 5;
  else if((gtimer04[1] != 0) || (gtimer04[2] != 0))
    lastshduan = 4;
  else if((gtimer03[1] != 0) || (gtimer03[2] != 0))
    lastshduan = 3;
  else if((gtimer02[1] != 0) || (gtimer02[2] != 0))
    lastshduan = 2;
  else
    lastshduan = 1;
 
  if(lastshduan >= 1)
  {
    if(Hour < gtimer01[2])            //judge the first period of time
    {
	flbzh = *(gtimep+lastshduan+lastshduan+lastshduan-3);   //flbzh = gtimer10[0];
	return;
    }
    if(Hour == gtimer01[2])
    {
      if(Minute < gtimer01[1])
      {
	flbzh = *(gtimep+lastshduan+lastshduan+lastshduan-3);   //flbzh = gtimer10[0];
	return;
      }
    }
  }
  if(lastshduan >= 2)
  {
    if(Hour < gtimer02[2])        //judge the second period of time
    {
	flbzh = gtimer01[0];
	return;
    }
    if(Hour == gtimer02[2])
    {
	if(Minute < gtimer02[1])
	{
	  flbzh = gtimer01[0];
	  return;
	}
    }
  }
  if(lastshduan >= 3)
  {
    if(Hour < gtimer03[2])           //judge the third period of time
    {	
      flbzh = gtimer02[0];
      return;
    }
    if(Hour == gtimer03[2])
    {
      if(Minute < gtimer03[1])
      {
	flbzh = gtimer02[0];
	return;
      }
    }
  }
  if(lastshduan >= 4)
  {
    if(Hour < gtimer04[2])           //judge the fourth period of time
    {
      flbzh = gtimer03[0];
      return;
    }
    if(Hour == gtimer04[2])
    {
      if(Minute < gtimer04[1])
      {
	flbzh = gtimer03[0];
	return;
      }
    }
  }
  if(lastshduan >= 5)
  {
    if(Hour < gtimer05[2])           //judge the fifth period of time
    {
      flbzh = gtimer04[0];
      return;
    }
    if(Hour == gtimer05[2])
    {
      if(Minute < gtimer05[1])
      {
	flbzh = gtimer04[0];
	return;
      }
    }
  }
  if(lastshduan >= 6)
  {
    if(Hour < gtimer06[2])           //judge the sixth period of time
    {
      flbzh = gtimer05[0];
      return;
    }
    if(Hour == gtimer06[2])
    {
      if(Minute < gtimer06[1])
      {
	flbzh = gtimer05[0];
	return;
      }
    }
  }
  if(lastshduan >= 7)
  {
    if(Hour < gtimer07[2])           //judge the seventh period of time
    {
	flbzh = gtimer06[0];
    	return;
    }
    if(Hour == gtimer07[2])
    {
      if(Minute < gtimer07[1])
      {
	flbzh = gtimer06[0];
	return;
      }
    }
  }
  if(lastshduan >= 8)
  {
    if(Hour < gtimer08[2])           //judge the eighth period of time
    {	flbzh = gtimer07[0];
	return;
    }
    if(Hour == gtimer08[2])
    {
      if(Minute < gtimer08[1])
      {
  	flbzh = gtimer07[0];
	return;
      }
    }
  }
  flbzh = *(gtimep+lastshduan+lastshduan+lastshduan-3);
}


void movedata(int x,int y,int n)
{
   int i;
   char *p,*q;
   p=(char*)x;
   q=(char*)y;
   for(i=0;i<n;i++)
   {
      *q=*p;
       q++;
       p++;
   }
}   
/*
void CountXL(void)
{
   if(xlsign>=10)
   {
      zdxl=pulse1*0.01; 
      glys1=((pulse1*0.1)*(pulse1*0.1))+((pulse2*0.1)*(pulse2*0.1));
      glys=(pulse1*0.1)/sqrt(glys1);
      GLYSZ=glys;
      GLYSX=(glys-GLYSZ)*100;
      xlzs=zdxl;
      xlxs=(zdxl-xlzs)*10000;
      if(xlzs>=ZDXLZ)  
      {if(xlzs==ZDXLZ)
          
          {
             ZDXLZ=zdxl;
             if(xlxs>ZDXLX)   
             {
               ZDXLX=(zdxl-ZDXLZ)*10000;
               movedata(0x204,0x240,8);
               movedata(0x228,0x23C,4);
             }  
           }
           else
           {
              ZDXLZ=zdxl;    
              ZDXLX=(zdxl-ZDXLZ)*10000;
              movedata(0x204,0x240,8);
              movedata(0x228,0x23C,4);
           }
       }   
       ADDRI2C0=0x28;
       ADDRI2C1=0;   
       write_data(0x228,20);                        
       xlsign=1;
       pulse1=0;
       pulse2=0;
   }
}
*/

⌨️ 快捷键说明

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