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

📄 cheshi.lst

📁 GSM MCU 开发板
💻 LST
📖 第 1 页 / 共 5 页
字号:
C51 COMPILER V7.50   CHESHI                                                                11/16/2008 00:57:23 PAGE 1   


C51 COMPILER V7.50, COMPILATION OF MODULE CHESHI
OBJECT MODULE PLACED IN cheshi.OBJ
COMPILER INVOKED BY: d:\green\Keil7.5\C51\BIN\C51.EXE cheshi.C BROWSE DEBUG OBJECTEXTEND

line level    source

   1          #include <cheshi.h>
   2          uchar data int_case;    //中断标志
   3          #define MAX_TM   90         // AT指收发数组最大缓冲
   4          #define MAX_T  60
   5          uchar idata uart_buff[MAX_TM]; //通信程序中的缓冲
   6          uchar idata send_count,receive_count;    //发送与接收 数组指针
   7          data uchar AT_Command_Type;             //当前发送的命令类型
   8          data uchar AT_Command_Status;           //命令发出以后的返回参数
   9          uchar idata para_temp[MAX_T];     //多用临时用
  10          uchar data read_tmp;             ///读电话本号参数
  11          uchar data num_tmp1;                    ///读短信号码参数
  12          uchar data TMP_BUF;         // 万用 值
  13          uchar data sms_tmp;                     ///短信处理参数代码
  14          uchar idata TEL_temp[20];   //存对方号码,
  15          #define IO_OUT                  P3_6  ///蜂鸣器
  16          uchar data system_server ;    //系统状态
  17          //多用值一般不用于多级
  18          uchar tmp_i,tmp_j ;
  19          //---定时用-----------
  20          uint  data timercount;          //50MS定时器,
  21          uchar data timer_1S_cnt;
  22          uchar data timer_10S_cnt;
  23          uchar data timer_S_cnt;
  24          //--------------------
  25          uchar idata LED_P0;
  26          uchar data ring_cnt;    //振铃用
  27          uchar idata PT2272_BUF;//存储用
  28          uchar bdata PT2272_TMP;  //无线控制
  29          sbit PT2272_D0=   PT2272_TMP^0;
  30          sbit PT2272_D1=   PT2272_TMP^1;
  31          sbit PT2272_D2=   PT2272_TMP^2;
  32          sbit PT2272_D3=   PT2272_TMP^3;
  33          sbit PT2272_VT=   PT2272_TMP^4;
  34          //位变量
  35          bit TC35_bit  ;
  36          bit ring_bit  ;  // 电话呼入 2
  37          bit PT2272_BIT;   //315M-是否连结到设备上
  38          
  39          bit txd_rxd_bit;    //接收正确的指令中断
  40          bit at_send_bit;    //发送允许
  41          
  42          
  43          // 中断 IO 模拟脚
  44          bit io_p00_bit;
  45          bit io_p01_bit;
  46          bit io_p02_bit;
  47          bit io_p03_bit;
  48          bit io_p04_bit;
  49          bit io_p05_bit;
  50          bit io_p06_bit;
  51          bit io_p07_bit;
  52          // IO设置开启与关闭
  53          bit io_p00_on;
  54          bit io_p01_on;
  55          bit io_p02_on;
C51 COMPILER V7.50   CHESHI                                                                11/16/2008 00:57:23 PAGE 2   

  56          bit io_p03_on;
  57          bit io_p04_on;
  58          bit io_p05_on;
  59          bit io_p06_on;
  60          bit io_p07_on;
  61          
  62          
  63           //uchar Read_Call_ID(void);
  64          
  65           //硬件处理
  66          void int_p02() // 发短中文短信前设置。 P0.2灯闪,同时蜂鸣器长叫一声
  67          {
  68   1           LED_INT2=1; BELL=0;
  69   1           for(tmp_i=0;tmp_i<8;tmp_i++)    //灯闪三下
  70   1           {  timercount=0;  while(timercount<10) watch_dog_clear;
  71   2              LED_INT2=~LED_INT2;
  72   2           }
  73   1           BELL=1; LED_INT2=0; io_p02_on=1;
  74   1      
  75   1            read_tmp=0x31;  TMP_BUF=0;    //读电话本1
  76   1                PHONE_RD(); para_temp[TMP_BUF++]=0x0d;para_temp[TMP_BUF++]=0x00;
  77   1                TMP_BUF=0;   // 将读出的电话号码转存起来,做发送对方号码
  78   1                do{
  79   2                     TEL_temp[TMP_BUF]=para_temp[TMP_BUF];  TMP_BUF++;
  80   2                  }while( TMP_BUF<=18);
  81   1            sms_tmp=smss_para;   //回中文短信
  82   1            send_sms(); //调用发短信
  83   1      
  84   1      }
  85          
  86          //硬件处理
  87          void int_p03() // 发短中文短信前设置。 P0.2灯闪,同时蜂鸣器长叫一声
  88          {
  89   1           LED_INT2=1; BELL=0;
  90   1           for(tmp_i=0;tmp_i<8;tmp_i++)    //灯闪三下
  91   1           {  timercount=0;  while(timercount<10) watch_dog_clear;
  92   2              LED_INT2=~LED_INT2;
  93   2           }
  94   1           BELL=1; LED_INT2=0; io_p02_on=1;
  95   1      
  96   1            read_tmp=0x31;  TMP_BUF=0;    //读电话本1
  97   1                PHONE_RD(); para_temp[TMP_BUF++]=0x0d;para_temp[TMP_BUF++]=0x00;
  98   1                TMP_BUF=0;   // 将读出的电话号码转存起来,做发送对方号码
  99   1                do{
 100   2                     TEL_temp[TMP_BUF]=para_temp[TMP_BUF];  TMP_BUF++;
 101   2                  }while( TMP_BUF<=18);
 102   1            sms_tmp=smss_tel;//英文短信回
 103   1            send_sms();       //  //调用发短信
 104   1      
 105   1      }
 106          
 107          //------------------------
 108          //----------------------
 109          //--定时器中断位,是整个程序的心跳,如果停止,程序会死机
 110          void  Int_Timer0(void) interrupt 1 using 3
 111          {
 112   1               TH0 = 0xB8;
 113   1                       TL0 = 0x00; //20ms的时钟基准
 114   1          watch_dog_clear;
 115   1         timer_1S_cnt++;   timercount++;
 116   1         if(timer_1S_cnt==50)    //20×50=1000MS  =1S
 117   1          { timer_10S_cnt++; timer_1S_cnt=0;
C51 COMPILER V7.50   CHESHI                                                                11/16/2008 00:57:23 PAGE 3   

 118   2            timer_S_cnt++;
 119   2                LED_INT0=~LED_INT0;
 120   2      
 121   2          }                              //1秒=1000毫秒
 122   1          if(timer_10S_cnt==10)   //10S
 123   1          {
 124   2                 timer_10S_cnt=0;
 125   2      
 126   2              }
 127   1      
 128   1        //---------硬件中断处理---------------------------------------------------------------------
 129   1         //-------P2.7-D0,P2.6-D1,P2.5-D2,P2.4-D3,    P2.3-VT-315M有信号中断,----------------------------
 130   1         //如果有PT2272接入 P2接入口会为低,P2.3-P2.7=0;
 131   1          P2=0xff;
 132   1          PT2272_BUF= P2&0x0F;     //加VT就是0xf1
 133   1          if(PT2272_BUF==0)  //状态检测
 134   1          {    PT2272_BIT=1; //可以进行中断
 135   2          }
 136   1      
 137   1          else if(((PT2272_BUF>0)&&((PT2272_BUF&0x0f)!=0x0f))&&PT2272_BIT==1) //这种方法只用于PT2272-M4的芯片
 138   1          {   PT2272_TMP= PT2272_BUF;
 139   2              PT2272_BIT=0;
 140   2          }
 141   1          //---------------------------
 142   1      
 143   1          IO_P25=1;        //外部中断 P25口
 144   1              if((io_p00_bit!=IO_P25))
 145   1              {
 146   2                      if(IO_P25==0)
 147   2                      { io_p00_on=0;
 148   3                      }
 149   2      
 150   2                      io_p00_bit=IO_P25;
 151   2              }
 152   1          IO_P24=1;        //外部中断 P24口
 153   1              if((io_p02_bit!=IO_P24))
 154   1              {
 155   2                      if(IO_P24==0)
 156   2                      { io_p02_on=0;
 157   3                      }
 158   2      
 159   2                      io_p02_bit=IO_P24;
 160   2              }
 161   1              IO_P35=1;        //外部中断 P35口
 162   1              if((io_p03_bit!=IO_P35))
 163   1              {
 164   2                      if(IO_P35==0)
 165   2                      { io_p03_on=0;
 166   3                      }
 167   2      
 168   2                      io_p03_bit=IO_P35;
 169   2              }
 170   1      
 171   1        //---------------------------------------------------------------------------------
 172   1      
 173   1      }
 174          /*****************************************************************************
 175           *                   TC35 的命令列表,与中断服务程序                          *
 176           *****************************************************************************/
 177          void  Int_Uart(void) interrupt 4 using 3  //串口的中断程序
 178          {
 179   1              if(TI)//数据模式与命令方式共用
C51 COMPILER V7.50   CHESHI                                                                11/16/2008 00:57:23 PAGE 4   

 180   1              {
 181   2                      TI=0;
 182   2      
 183   2                              if(send_count>=MAX_TM-5)  send_count=0;   //不在超过最大值
 184   2      
 185   2                              if((uart_buff[send_count]==0)) //应该检测命令结束代码,检测到时结束通信
 186   2                              {
 187   3                              at_send_bit=1;  ////接收允许
 188   3                              send_count=0xff; // 发送指针 达到是大值
 189   3                              uart_buff[0]=0;         //清除接收缓冲区
 190   3                              receive_count=0;
 191   3                               return;
 192   3                  }
 193   2                              else
 194   2                              {   if(uart_buff[send_count]<=0xB0)
 195   3                                        SBUF=uart_buff[send_count++];
 196   3      
 197   3                         if((uart_buff[send_count]==0)) //应该检测命令结束代码,检测到时结束通信
 198   3                                              { at_send_bit=1; //接收允许
 199   4                               send_count=0xff;
 200   4                               uart_buff[0]=0;                //清除接收缓冲区
 201   4                               receive_count=0;    return;
 202   4                              }
 203   3                              }
 204   2      
 205   2      
 206   2              receive_count=0;
 207   2          }
 208   1      
 209   1              else
 210   1              if(RI) //命令方式
 211   1                      {
 212   2                      RI=0;
 213   2                      if(at_send_bit==0)      return; //如果在发送时,不能接收
 214   2                      if((send_count==0xff)&&(receive_count<MAX_TM-3))//没有发送时才能进行接收
 215   2                      {       //所有的命令返回都是处于 0x0A [Result] 0x0D 之间,其他命令,不会出现这种情况
 216   3                      uart_buff[receive_count++]=SBUF;
 217   3                      }
 218   2                       else
 219   2                       {   receive_count=0;
 220   3                               return;
 221   3                       }
 222   2                        if(receive_count>=MAX_TM-3)
 223   2                      {
 224   3                              if(AT_Command_Type==SMS_CMGR)    receive_count=0;
 225   3      
 226   3                              else
 227   3                                       {      receive_count=0;
 228   4                                              AT_Command_Status=COMMAND_OK;
 229   4                                      return;
 230   4                                       }
 231   3                                   receive_count=0;
 232   3                              }
 233   2      
 234   2              if((receive_count==2)&&(uart_buff[1]==0x0d))//没有包含为其他信息的命令返回
 235   2                      {//接收到一个命令回应,可能为,0-OK  1-CONNECT 2-RING 3-NO CARRIER 4-ERROR
 236   3                              //只返回OK
 237   3      
 238   3                              if(uart_buff[0]=='0')
 239   3                              { AT_Command_Status=COMMAND_OK;  //txd_rxd_bit=1;
 240   4                              }
 241   3                              if(uart_buff[0]=='2')    //电话呼入
C51 COMPILER V7.50   CHESHI                                                                11/16/2008 00:57:23 PAGE 5   

 242   3                              {    ring_bit=1;  ring_cnt++;
 243   4                                       AT_Command_Status=COMMAND_OK;  //txd_rxd_bit=1;

⌨️ 快捷键说明

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