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

📄 tc35i.lst

📁 TC35_GSM
💻 LST
📖 第 1 页 / 共 2 页
字号:
C51 COMPILER V7.06   TC35I                                                                 10/01/2009 22:01:36 PAGE 1   


C51 COMPILER V7.06, COMPILATION OF MODULE TC35I
OBJECT MODULE PLACED IN tc35i.OBJ
COMPILER INVOKED BY: C:\Keil\C51\BIN\C51.EXE tc35i.c DEBUG OBJECTEXTEND

stmt level    source

   1          /******************************************************************
   2          ** 单片机与控制TC35I读短信并控制相应的动作
   3          ** 晶 振  频 率:11.0592M
   4          
   5          ******************************************************************/
   6          #include<reg51.h>       
   7          #include <string.h>     
   8          
   9          #define buf_max 72   //缓存长度72
  10          
  11          unsigned char i=0; 
  12          unsigned char *send_data;//要发送的数据
  13          unsigned char rec_buf[buf_max];//接收缓存 
  14          
  15          /************************函数声明********************************/
  16          void Ini_UART(void);   //串口初始化
  17          void delay(unsigned int delay_time);//延时函数   
  18          bit hand(unsigned char *a);//判断缓存中是否含有指定的字符串 
  19          void clr_buf(void);//清除缓存内容 
  20          void clr_ms(void);//清除信息
  21          void send_ascii(unsigned char *b);//发送ascii数据 
  22          void send_hex(unsigned char b);//发送hex数据 
  23          unsigned int htd(unsigned int a);//十六进制转十进制
  24          void  Serial_init(void);//串口中断处理函数
  25          void  Mes_To_Call(void);
  26          /***************************************************************/
  27          
  28          void main(void)
  29          {       
  30   1          Ini_UART();   //串口初始化
  31   1                
  32   1              while(1)     //单片机和模块连接成功
  33   1              { 
  34   2                 Mes_To_Call();
  35   2          }
  36   1      }
  37          /**************************串口初始化函数****************************/
  38          /*函数原型:void Ini_UART(void
  39          /*函数功能:串口初始化
  40          /*输入参数:无
  41          /*输出参数:无
  42          /*调用模块:无
  43          /******************************************************************/ 
  44          void Ini_UART(void)   //串口初始化
  45          {
  46   1          unsigned char k;
  47   1          
  48   1          TMOD=0x20;            //定时器1--方式2
  49   1          TL1=0xfa;             
  50   1          TH1=0xfa;             //11.0592MHZ晶振,波特率为4800
  51   1          SCON=0x50;           //方式1
  52   1          TR1=1;               //启动定时     
  53   1              ES=1;  
  54   1              EA=1; 
  55   1              for(k=0;k<20;k++)
C51 COMPILER V7.06   TC35I                                                                 10/01/2009 22:01:36 PAGE 2   

  56   1                  delay(65535);
  57   1              while(!hand("OK"))  //用于指示单片机和模块连接
  58   1              {       
  59   2              send_ascii("AT");      //发送联机指令 
  60   2                  send_hex(0x0d); 
  61   2                  for(k=0;k<10;k++)
  62   2                      delay(65535);           
  63   2              }               
  64   1              clr_buf();
  65   1              send_ascii("AT+CNMI=2,1"); //新短信提示 
  66   1              send_hex(0x0d);  
  67   1              while(!hand("OK"));
  68   1              clr_buf();
  69   1              send_ascii("AT+CMGF=1");  //TEXT模式 
  70   1              send_hex(0x0d);  
  71   1              while(!hand("OK"));     
  72   1              clr_buf(); 
  73   1          clr_ms();                //删除短信
  74   1      }
  75          /**************************发送字符(ASCII码)函数*********************/
  76          /*函数原型:void send_ascii(unsigned char *b)
  77          /*函数功能:发送字符(ASCII码)
  78          /*输入参数:unsigned char *b
  79          /*输出参数:无
  80          /*调用模块:无
  81          /******************************************************************/ 
  82          void send_ascii(unsigned char *b)         
  83          {
  84   1           ES=0;       //串行口禁止中断
  85   1          for (b; *b!='\0';b++)
  86   1          {
  87   2              SBUF=*b;
  88   2              while(TI!=1);
  89   2                      TI=0;   //定时器中断
  90   2              }         
  91   1          ES=1;       //串行口允许中断
  92   1      }
  93          
  94          
  95          /**************************发送字符(十六进制)函数*********************/
  96          /*函数原型:void send_ascii(unsigned char b)
  97          /*函数功能:发送字符(十六进制)
  98          /*输入参数:unsigned char b
  99          /*输出参数:无
 100          /*调用模块:无
 101          /******************************************************************/ 
 102          void send_hex(unsigned char b)         
 103          {
 104   1          ES=0;
 105   1          SBUF=b;
 106   1          while(TI!=1);
 107   1          TI=0;
 108   1          ES=1;
 109   1      }
 110          
 111          /**************************清除缓存数据函数****************************/
 112          /*函数原型:void clr_buf(void)
 113          /*函数功能:清除缓存数据
 114          /*输入参数:无
 115          /*输出参数:无
 116          /*调用模块:无
 117          /**********************************************************************/
C51 COMPILER V7.06   TC35I                                                                 10/01/2009 22:01:36 PAGE 3   

 118          void clr_buf(void)
 119          {
 120   1          for(i=0;i<buf_max;i++)
 121   1                  rec_buf[i]=0;
 122   1              i=0;
 123   1      }
 124          
 125          /****************************清除短信函数*****************************/
 126          /*函数原型:void clr_ms(void)
 127          /*函数功能:清除短信
 128          /*输入参数:无
 129          /*输出参数:无
 130          /*调用模块:无
 131          /**********************************************************************/
 132          void clr_ms(void)
 133          {
 134   1          unsigned char a,b,c,j; 
 135   1              send_ascii("AT+CPMS?");//删除短信
 136   1              send_hex(0x0d); 
 137   1              while(!hand("OK"));     
 138   1          a=*(strstr(rec_buf,"+CPMS")+12);
 139   1          b=*(strstr(rec_buf,"+CPMS")+13);  
 140   1              c=*(strstr(rec_buf,"+CPMS")+14);
 141   1              clr_buf();                      
 142   1              if(b==',')
 143   1              {         
 144   2                  for(j=0x31;j<(a+1);j++)
 145   2                      {
 146   3                          send_ascii("AT+CMGD=");//
 147   3                              send_hex(j);
 148   3                      send_hex(0x0d); 
 149   3                      while(!hand("OK"));
 150   3                          clr_buf();          
 151   3                      }
 152   2              }
 153   1              else if(c==',')
 154   1              {         
 155   2                  for(j=1;j<((a-0x30)*10+(b-0x30)+1);j++)
 156   2                      { 
 157   3                          send_ascii("AT+CMGD=");//
 158   3                              if(j<10)
 159   3                              send_hex(j+0x30);

⌨️ 快捷键说明

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