程序功能

[复制链接]
405|9
手机看帖
扫描二维码
随时随地手机跟帖
lium|  楼主 | 2018-7-10 19:02 | 显示全部楼层 |阅读模式

void time0()interrupt 1 using 1//T/C0中断服务程序入口
{
uint dac0;
uchar x,y;
uchar i,j=0,a;
sbr ++;
TH0=(65536-49981)/256;//计数初值重新装入
TL0=(65536-49981)%256;
if(sbr==2)
{
       time1++;
       sbr=0;
       i=P1;
       j=0x02;
       if(i&j)
       {
          if(time1==time)
           {
               time1=0;
               i=P1;
               j=0x01;
               if(i&j)     //1
               {
                  if(sh)
                  {
                     if(dac>0)
                     {
                        dac=dac--;
                        pl=pl--;
                     }
                     else
                     {
                        dac=0;
                        pl=0;
                     }
                  }
                  else
                  {
                         if(dac>tiao)
                     {
                        dac=dac-tiao;
                        pl=pl-tiao;
                     }
                     else
                     {
                        dac=0;
                        pl=0;
                     }
                  }
               }
               else   //1
               {
                  if(sh)
                  {
                     if(dac<1000-tiao)
                     {
                        dac=dac+tiao;
                        pl=pl+tiao;
                     }
                     else
                     {
                        dac=1000;
                        pl=1000;
                     }
                  }
                  else
                  {
                     if(dac<1000)
                     {
                        dac++;
                        pl++;
                     }
                     else
                     {
                        dac=1000;
                        pl=1000;
                     }
                  }
               }
             sh=i&j;
           }
       }
       else
       {
          i=P1;
          j=0x0c;
          a=i&j;
          if(a==0x04)
          {
              if(dac>0)
              {dac--;
              pl--;}
              else
              {dac=0;
              pl=0;}
          }
          else if(a==0x08)
          {
              if(dac<1000)
              {dac++;
              pl++;}
              else
              {dac=1000;
               pl=1000;
              }
          }
       }
        x=dac/256;
        y=dac%256;
       dac0=dac*4;
      tlv_5616(da); //调用da程序;
      wrnbyt(0xa0,0x00,x);
      wrnbyt(0xa0,0x01,y);
}
}
这段程序大概什么功能?
llia| | 2018-7-10 19:04 | 显示全部楼层

UINT类型是unsigned int派生出来的
uchar等价于unsigned char

使用特权

评论回复
guoyt| | 2018-7-10 19:08 | 显示全部楼层


wrnbyt(0xa0,0x00,x);
这个估计是自己定义的函数

使用特权

评论回复
lium|  楼主 | 2018-7-10 19:10 | 显示全部楼层

这里sbr ++;是个什么

使用特权

评论回复
yufe| | 2018-7-10 19:12 | 显示全部楼层
有很多  if else有没注释,一下子很难看懂

使用特权

评论回复
wangpe| | 2018-7-10 19:14 | 显示全部楼层
sbr 是宏定义, 一进到这个中断就先把sbr+1 , 估计是这样子...

使用特权

评论回复
lium|  楼主 | 2018-7-10 19:16 | 显示全部楼层
没人能说个所以然啊。。。。

使用特权

评论回复
juventus9554| | 2018-7-10 19:19 | 显示全部楼层
这个变量名称定义太不规范,要是程序大了,看起来要人命

使用特权

评论回复
guoyt| | 2018-7-10 19:22 | 显示全部楼层
对一些变量所代表的的东西不懂

使用特权

评论回复
lium|  楼主 | 2018-7-10 19:24 | 显示全部楼层
哦,看来我想错了,结贴

使用特权

评论回复
发新帖 我要提问
您需要登录后才可以回帖 登录 | 注册

本版积分规则

915

主题

9579

帖子

3

粉丝