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

📄 cheshi.lst

📁 GSM MCU 开发板
💻 LST
📖 第 1 页 / 共 5 页
字号:
 748   1              send_count=0xff;timer_S_cnt=0;
 749   1              while(timer_S_cnt<15&&(AT_Command_Status==COMMAND_WAIT))
 750   1                      {   if(strsearch("+CMGS:"))   break;
 751   2                          else if(txd_rxd_bit) break;
 752   2                              watch_dog_clear;
 753   2                      }
 754   1      
 755   1                       //  num_tmp1为短信号, 从16进制转成 文本方式才能发送出去
 756   1                      para_temp[0]=(num_tmp1/10)+0x30;
 757   1                      para_temp[1]=(num_tmp1%10)+0x30;
 758   1                      para_temp[2]=0x0d;para_temp[3]=0x00;
 759   1                              Send_AT_Command(SMS_CMGD);//删除处理完的短信
 760   1                              timer_S_cnt=0; while(timer_S_cnt<2&&(AT_Command_Status==COMMAND_WAIT)) watch_dog_clear;
 761   1                  Send_AT_Command(SIM_ID);
 762   1                   if(TC35_bit==0)
 763   1                   Send_AT_Command(SMSS_ID);
 764   1                //   IO_OUT=1;
 765   1                    for(i=0;i<=MAX_TM-2;i++)
 766   1                      {      uart_buff[i]=0;
 767   2                              }
 768   1      }
 769          //======================================================================
 770          //================进行SIM卡的电话本读======================================================
 771          //======================================================================
 772          uchar PHONE_RD( )      //read_tmp=0x30+i;  要读的电话号码
 773          {       uchar j;
 774   1      
 775   1              Send_AT_Command(PHONE_READ);
 776   1              send_count=0;
 777   1              timer_S_cnt=0; while(timer_S_cnt<1&&(AT_Command_Status==COMMAND_WAIT)) watch_dog_clear;
 778   1      
 779   1              if(j=strsearch("+CPBR:"))    //+CPBW: 1,"13818120592",129,"chia"
 780   1              {       j=j+9;
 781   2      
 782   2                       do
 783   2                      {
 784   3                                      para_temp[TMP_BUF++]= uart_buff[j++];
 785   3                                      if( uart_buff[j]=='"')
 786   3                                      {       //para_temp[t++]=';';para_temp[t++]=0x0d;para_temp[t++]=0x00;
 787   4                                         return(TMP_BUF);
 788   4                                      }
 789   3      
 790   3      
 791   3                      }while(j<=24);
 792   2      
 793   2      
 794   2             }
 795   1             else if(uart_buff[1]==0x0d&&uart_buff[0]==0x34)
 796   1                 {           return(FALSE);
 797   2                      }
 798   1              else return(FALSE);
 799   1      }
C51 COMPILER V7.50   CHESHI                                                                11/16/2008 00:57:23 PAGE 14  

 800          
 801          //======================================================================
 802          //========================进行SIM卡中的1到20条短信号码的读==============================================
 803          //======================================================================
 804          uchar   READ_TEL(uchar r)                //读短信号码1-20个
 805          {     uchar i;
 806   1                for(i=0;i<=10;i++)  uart_buff[i]=0;
 807   1                para_temp[0]=(r/10)+0x30;para_temp[1]=(r%10)+0x30; para_temp[2]=0; para_temp[3]=0;
 808   1            Send_AT_Command(SMS_CMGR);
 809   1            timercount=0; while(timercount<2) ;
 810   1             return(0);
 811   1      
 812   1      }
 813          
 814          
 815          
 816          
 817          void Initialize_Model(void)    //初始化 PIN检测
 818          {
 819   1              uchar i;
 820   1          Sys_Init();
 821   1      
 822   1              P0=0;//IO_IGT=1;
 823   1          PT2272_BIT=0;PT2272_TMP=0;//
 824   1              io_p01_on=1; io_p00_on=1;
 825   1              io_p02_on=1;io_p01_bit=0;
 826   1              io_p03_on=1;    io_p02_bit =0;
 827   1                      for(i=0;i<12;i++)
 828   1              {//进行初始化,并显示
 829   2                      Send_AT_Command(TC35_INIT);
 830   2                      if(uart_buff[1]==0x0d&&uart_buff[0]==0x30)
 831   2                      {  break;}
 832   2              else if(uart_buff[receive_count-1]==0x0d&&uart_buff[receive_count-2]=='0')
 833   2               {  break;}
 834   2                       if((i%4)==0)
 835   2                      {
 836   3                              IO_IGT=1;
 837   3                      }
 838   2                      else if((i%2)==0)
 839   2                      {
 840   3                              IO_IGT=0;
 841   3                      }
 842   2                      timer_S_cnt=0; while(timer_S_cnt<5&&(AT_Command_Status==COMMAND_WAIT)) watch_dog_clear;
 843   2      
 844   2          }
 845   1          if(i>=11)   goto at_eer;
 846   1      
 847   1      
 848   1              for(i=0;i<12;i++)
 849   1              {
 850   2                      if(Send_AT_Command(CHECK_PIN))
 851   2                      {//如有收到回应进行分析收到的信息,
 852   3                                      uart_buff[receive_count]=0;
 853   3                                      if(strsearch("READY")!=0)
 854   3                                      break;
 855   3                      }
 856   2                timer_S_cnt=0; while(timer_S_cnt<2&&(AT_Command_Status==COMMAND_WAIT)) watch_dog_clear;
 857   2                //LED_INT=~LED_INT;
 858   2              }
 859   1         if(i>=11)
 860   1          {
 861   2      at_eer:      Send_AT_Command(RESET_TC35);
C51 COMPILER V7.50   CHESHI                                                                11/16/2008 00:57:23 PAGE 15  

 862   2              timer_S_cnt=0;while(timer_S_cnt<2) watch_dog_clear;
 863   2              Send_AT_Command(SMSS_ID);
 864   2              //      timer_S_cnt=0; while(timer_S_cnt<2&&(AT_Command_Status==COMMAND_WAIT)) watch_dog_clear;
 865   2      
 866   2          //eer_int=15;
 867   2              timer_S_cnt=0; while(timer_S_cnt<10) watch_dog_clear;
 868   2      
 869   2          }
 870   1          BELL=0;
 871   1              IO_IGT=0;
 872   1              Send_AT_Command(SIM_ID);
 873   1              Send_AT_Command(AT_IPR);
 874   1              BELL=1;
 875   1      
 876   1              Send_AT_Command(REQUEST_MOD);
 877   1              if(strsearch("TC35\x0d\x0a")==0)
 878   1        {Send_AT_Command(SMSS_ID); TC35_bit=0;}
 879   1          else TC35_bit=1;
 880   1         timer_S_cnt=0; while(timer_S_cnt<7) watch_dog_clear;
 881   1         Send_AT_Command(SMSS_ID);
 882   1      
 883   1      }
 884          
 885          
 886          
 887          
 888          void  Sys_Init(void)//话机启动的初始化程序,包含键盘与定时器,串口等
 889          {
 890   1                              //TH0=(65536-46080)/256;//重新装入定时25mS的初值到TH0,TL0     56320
 891   1                              //TL0=(65536-46080)%256;
 892   1                              //65536-(11.0592/12)*20MS*1000=To    18432     47104
 893   1                              //1ms定时
 894   1                              //11.0592/12 = 0.9216 M (记数频率)
 895   1                              //1ms记数 921.6次
 896   1                              //16位 2^16 - x = 922 x=64614 FC66
 897   1                              //定时器里不断放fc66,不用怀疑51定时器得到的 1ms的精确性吗
 898   1      
 899   1      
 900   1      
 901   1      
 902   1         //   TH0 = 0xf6;
 903   1         // TL0 = 0x50;
 904   1      
 905   1              TH0 = 0xB8;TL0 = 0x00; //20ms的时钟基准
 906   1      
 907   1        //串口中断
 908   1          TI=0; RI=0;
 909   1          SCON=0x50;                  //选用方式1
 910   1          TMOD=0x20;
 911   1          TMOD = (TMOD & 0xf0) | 1;//MODE 1
 912   1         // TH1=0xe8;              //波特率为9600
 913   1         // TL1=0xe8;
 914   1         TH1=0xfd;              //波特率为9600
 915   1         TL1=0xfd;
 916   1          PCON=0x00;            //倍频0x80
 917   1          IE = 0xb0;          // EA XX ET2 ES ET0 EX0 ET1 EX1
 918   1          TR1=1;              //enable TIMER1
 919   1      
 920   1          ES=1;  //开串口开断
 921   1          TR0=1; //串口接收中断
 922   1          ET0=1;  //T0 中断
 923   1          ET1=0;  // T1 中断
C51 COMPILER V7.50   CHESHI                                                                11/16/2008 00:57:23 PAGE 16  

 924   1          EA=1;
 925   1          P0=0xFF;
 926   1          P1=0xFF;
 927   1          P2=0xFF;
 928   1          P3=0xFF;
 929   1         // P4=0xff;
 930   1          timer_1S_cnt=0;
 931   1          receive_count=0;
 932   1          IO_IGT=1;send_count=0xff;           //表示禁止发送,可以接收
 933   1      
 934   1         LED_INT3=1;LED_INT7=0;
 935   1          io_p06_on=1;IO_IGT=0;
 936   1          IO_OUT=1;
 937   1      
 938   1      }
 939           //======================================================
 940          //这里为AT指令处理区,所有的AT指令都在这时对uart_buff数组进行赋值,并发送出去,
 941          //-正常情况下,AT指令反回也会在这里接收完
 942            //------------------------
 943            //-----------------------
 944            ///==========================================
 945          
 946          uchar  Send_AT_Command( uchar type)      //发送AT指令
 947          //拨号时号码放在phone.number
 948          //其他用para_temp
 949          {
 950   1              AT_Command_Type=type;
 951   1              send_count=0;
 952   1          switch(type)
 953   1          {
 954   2      
 955   2              case VOICE_DIAL:        //语音拨号
 956   2              strcpy(uart_buff,"ATD");
 957   2              strcat(uart_buff,para_temp);
 958   2            // strcpy(uart_buff,"ATD10086;");
 959   2             //strcat(uart_buff,";");
 960   2      
 961   2              break;
 962   2            case RESET_TC35:          //复位TC35
 963   2              strcpy(uart_buff,"AT+CFUN=1,1");
 964   2              break;
 965   2            case CHECK_PIN:           //检查当前是否要输入PIN码
 966   2              strcpy(uart_buff,"AT+CPIN?");
 967   2              break;
 968   2      
 969   2            case TC35_INIT:           //TC35初始化命令     ATE0 ATV0 合体
 970   2              strcpy(uart_buff,"ATE0V0");
 971   2              break;
 972   2              //0D 0A 54 43 33 35 0D 0A
 973   2            case   REQUEST_MOD:   //模块版型号
 974   2              strcpy(uart_buff,"AT+CGMM");
 975   2              break;
 976   2      
 977   2            case SIM_ID:    // 也是合体组合  ATE0 ATV0 AT+CMGF=1 AT+CNMI=2,1
 978   2                strcpy(uart_buff,"ATE0V0+CMGF=1+CNMI=2,1");
 979   2              break;
 980   2             case  AT_IPR:   // 波特率 9600
 981   2              strcpy(uart_buff,"AT+IPR=9600"); break;
 982   2                      case CALL_ID:                   //读来电显示
 983   2              strcpy(uart_buff,"AT+CLCC");
 984   2              break;
 985   2      
C51 COMPILER V7.50   CHESHI                                                                11/16/2008 00:57:23 PAGE 17  

 986   2              case SMSS_ID:   //TC35i模块专用
 987   2                strcpy(uart_buff,"ATE0V0^SSMSS=1+CNMI=2,1");
 988   2              break;
 989   2            case HOOKOFF:                     //挂机,停止通话
 990   2              strcpy(uart_buff,"ATH");
 991   2              break;
 992   2            case SMS_CMGF:    //SMS 接收方式,
 993   2              strcpy(uart_buff,"ATE0V0+CMGF=0");
 994   2              break;
 995   2      
 996   2            case PHONE_WRITE:         //存电话号码
 997   2              strcpy(uart_buff,"AT+CPBW=");
 998   2              strcat(uart_buff,para_temp);
 999   2              break;

⌨️ 快捷键说明

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