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

📄 rmeter.lst

📁 红外抄表。CPU = LPC921F
💻 LST
📖 第 1 页 / 共 2 页
字号:
C51 COMPILER V7.00  RMETER                                                                 01/06/2007 20:27:22 PAGE 1   


C51 COMPILER V7.00, COMPILATION OF MODULE RMETER
OBJECT MODULE PLACED IN rMeter.OBJ
COMPILER INVOKED BY: C:\Keil\C51\BIN\C51.EXE rMeter.c

stmt level    source

   1          #include <REG922.H>
   2          
   3          #include "rMeter.h"
   4          
   5          struct FLASH_SET code FLA_set[MAX_METER]={{0,0,0,50,0,0},{0,0,0,50,0,0},{0,0,0,50,0,0},
   6                                                                                                  {0,0,0,50,0,0},{0,0,0,50,0,0},{0,0,0,50,0,0},
   7                                                                                                  {0,0,0,50,0,0},{0,0,0,50,0,0}};
   8          uchar code FLApluseL[MAX_METER][100];
   9          uchar code FLAinMark[MAX_METER]={0x01,0x02,0x04,0x08,0x10,0x20,0x40,0x80};
  10          
  11          uchar ucRbuf[BUF_SIZE];
  12          uchar ucOffset;
  13          uint unPluseCnt[MAX_METER];
  14          uchar *pucData,*pucAddr;
  15          
  16          
  17          
  18          //void   (*GotoIsp)();  //定义函数指针  
  19          void delay100us(uchar i);
  20          void UART_Init(void); 
  21          bit  WriteFlash(unsigned int unFlashAddr, unsigned char ucData); 
  22          void SendChar(unsigned char ucData);
  23          void T1_Init(void);
  24          
  25          
  26          //////////////////////////////////////////////////////////////////////////////////////////////////////////
             -/////
  27          void main()
  28          {
  29   1              uchar uctmp,ucPackOff;
  30   1              uint *punTail,untmp;
  31   1              uchar ucInState,ucOldState,ci,uccnt[MAX_METER];
  32   1              uchar ucInData;
  33   1      
  34   1              delay100us(100);
  35   1              delay100us(100);
  36   1      
  37   1      
  38   1              ucOffset=0;
  39   1              for(ci=0;ci<MAX_METER;ci++)
  40   1              {
  41   2                      unPluseCnt[ci]=FLA_set[ci].ucCurPluseH;
  42   2                      unPluseCnt[ci]=unPluseCnt[ci]*256+FLApluseL[ci][FLA_set[ci].unCurPluseLoff];
  43   2              }
  44   1      
  45   1              P0M1=0x80;
  46   1              P0M2=0x80;
  47   1      
  48   1              P1M1=0x00;
  49   1              P1M2=0x00;
  50   1      
  51   1      //      GotoIsp=0x0F00;  //for LPC921
  52   1      
  53   1      /*
  54   1              PCON=PCON&0xdf;     //配置成掉电中断 
C51 COMPILER V7.00  RMETER                                                                 01/06/2007 20:27:22 PAGE 2   

  55   1              PCON=PCON|0x10; 
  56   1              RSTSRC=RSTSRC&0x0f;    //清除上电和掉电检测标志位 
  57   1              IEN0=IEN0|0xa0;      //开掉电检测中断 
  58   1      */
  59   1      
  60   1              T1_Init();
  61   1              UART_Init(); 
  62   1      
  63   1              //test
  64   1              pucData=(uchar *)&unPluseCnt[1];
  65   1      //      uctmp=((uint)pucData)>>8;
  66   1      //      SendChar(uctmp);
  67   1      //      uctmp=((uint)pucData)&0xff;
  68   1      //      SendChar(uctmp);
  69   1              SendChar('\x33');
  70   1              SendChar(*pucData);
  71   1              SendChar(*(pucData+1));
  72   1      
  73   1      
  74   1              while(1)
  75   1              {
  76   2                      ucOldState = ucInState;
  77   2      //              ucInState = 0;
  78   2      
  79   2                      for(ci=0;ci<MAX_METER;ci++) uccnt[ci]=0;
  80   2                      for(uctmp=0;uctmp<5;uctmp++)
  81   2                      {
  82   3                              ucInData = ((P1 & 0x10)<<3);
  83   3      //                      ucInData = P1^4; ucInData <<=7;
  84   3      //                      if(P1^4) ucInData = 0x80;
  85   3      //                      else ucInData = 0;
  86   3      
  87   3                              ucInData |= (P0 & 0x7f);//////////
  88   3      
  89   3                              for(ci=0;ci<MAX_METER;ci++)
  90   3                              {
  91   4                                      if(ucInData & FLAinMark[ci])    uccnt[ci]++;
  92   4                              }
  93   3      
  94   3                              delay100us(2);
  95   3                      }
  96   2                      for(ci=0;ci<MAX_METER;ci++)
  97   2                      {
  98   3      /*
  99   3                              if(uccnt[ci]>3 && !(ucOldState & FLAinMark[ci]))  //0 -> 1
 100   3                              {
 101   3                                      for(uctmp=0;uctmp<5;uctmp++)
 102   3                                      {
 103   3      //                                      ucInData = ((P1 & 0x10)<<3);
 104   3                                              ucInData = P1^4; ucInData <<=7;
 105   3                                              ucInData |= (P0 & 0x7f);//////////
 106   3      
 107   3                                              if(ucInData & FLAinMark[ci]) uccnt[ci]++;
 108   3                                      }
 109   3                                      if(uccnt[ci]>7)
 110   3                                              ucInState |= FLAinMark[ci];
 111   3                              }
 112   3                              else if(uccnt[ci]<2 && (ucOldState & FLAinMark[ci]))    // 1 -> 0
 113   3                              {
 114   3                                      for(uctmp=0;uctmp<5;uctmp++)
 115   3                                      {
 116   3      //                                      ucInData = ((P1 & 0x10)<<3);
C51 COMPILER V7.00  RMETER                                                                 01/06/2007 20:27:22 PAGE 3   

 117   3                                              ucInData = P1^4; ucInData <<=7;
 118   3                                              ucInData |= (P0 & 0x7f);//////////
 119   3      
 120   3                                              if(ucInData & FLAinMark[ci]) uccnt[ci]++;
 121   3                                      }
 122   3                                      if(uccnt[ci]<3)
 123   3                                              ucInState &= (~FLAinMark[ci]);
 124   3                              }
 125   3      */                      
 126   3      
 127   3                              if(uccnt[ci]>3)
 128   3                                      ucInState |= FLAinMark[ci];
 129   3                              else if(uccnt[ci]<2 && (ucOldState & FLAinMark[ci]))
 130   3                                      ucInState &= (~FLAinMark[ci]);
 131   3      
 132   3                      }
 133   2      
 134   2      
 135   2                      for(ci=0;ci<MAX_METER;ci++)
 136   2                      {
 137   3                              if((ucOldState & FLAinMark[ci]) && !(ucInState & FLAinMark[ci]))
 138   3                              {
 139   4      
 140   4                                      unPluseCnt[ci]++;
 141   4      
 142   4      //test
 143   4      SendChar('\xCC');
 144   4      SendChar(ci+1);
 145   4      uctmp=unPluseCnt[ci];
 146   4      SendChar(uctmp);
 147   4      
 148   4      
 149   4                                      if(unPluseCnt[ci]==FLA_set[ci].unPlusePDgr)     //更新度数
 150   4                                      {
 151   5                                              untmp=FLA_set[ci].unCurDgr+1;
 152   5                                              pucData=(uchar *)&untmp;
 153   5                                              pucAddr=(uchar *)&FLA_set[ci].unCurDgr;
 154   5                                              WriteFlash((uint)pucAddr,*pucData);                             //保存度数
 155   5                                              WriteFlash((uint)(pucAddr+1),*(pucData+1));
 156   5      
 157   5                                              WriteFlash((uint)&FLA_set[ci].ucCurPluseH,'\0');        //脉冲数清0
 158   5                                              WriteFlash((uint)&(FLApluseL[ci]+FLA_set[ci].unCurPluseLoff),'\0');
 159   5                                              unPluseCnt[ci]=0;
 160   5      
 161   5      //test
 162   5      SendChar('\xDD');
 163   5      SendChar(*pucData);
 164   5      SendChar(*(pucData+1));
 165   5      
 166   5      
 167   5      
 168   5                                      }
 169   4                                      if(!(unPluseCnt[ci] & 0x00ff))  //发生低字节向高字节进位时
 170   4                                      {
 171   5                                              pucData=(uchar *)&unPluseCnt[ci];
 172   5                                              WriteFlash((uint)&FLA_set[ci].ucCurPluseH,*pucData);
 173   5                                              WriteFlash((uint)&(FLApluseL[ci]+FLA_set[ci].unCurPluseLoff),'\0');
 174   5      
 175   5      //test
 176   5      SendChar('\xAA');
 177   5      SendChar(FLA_set[ci].ucCurPluseH);
 178   5      SendChar(FLApluseL[ci][FLA_set[ci].unCurPluseLoff]);
C51 COMPILER V7.00  RMETER                                                                 01/06/2007 20:27:22 PAGE 4   

 179   5                                              
 180   5                                              
 181   5                                      }
 182   4                                      if(unPluseCnt[ci] % (FLA_set[ci].unPlusePDgr / WRITE_TIMES)==0)
 183   4                                      {
 184   5                                              pucData=(uchar *)&unPluseCnt[ci];
 185   5                                              pucData++;
 186   5                                              WriteFlash((uint)&(FLApluseL[ci]+FLA_set[ci].unCurPluseLoff),*pucData);
 187   5      
 188   5      uctmp=*pucData;
 189   5      //test
 190   5      /*
 191   5      SendChar('\xBB');

⌨️ 快捷键说明

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