中科因仑“3+1”工程特种兵精英论坛

标题: 串口中断接收到振铃信号后继电器吸合 [打印本页]

作者: 张衍波    时间: 2015-5-13 09:32
标题: 串口中断接收到振铃信号后继电器吸合
/**********************************************************
             GTM900-B工业模块模块测试程序           
程序功能:远程控制两路继电器的吸合与断开\远程控制两路开关
                  打电话控制
单片机型号:STC12C5A60S2  支持双串口

晶振:11.0592M         波特率:9600bps

应用软件:Keil2或Keil3                                               
                                                                                                                                       
发布时间:2011-12—10

公司:汇诚科技

作    者:QQ790244909  旺旺:电子开发直销           
**********************************************************/
#include<reg52.h>
#include<intrins.h>
#define uchar unsigned char
#define uint unsigned int
uchar cou_rec=0;   //接收计数
uchar date_rec[]; //接收数据
uchar i=0;
uchar code RING[]="RING\r";
sbit jdq1=P0^0;
sbit jdq2=P0^1;
void delay(uint z)
{
  uint x,y;
  for(x=z;x>0;x--)
     for(y=110;y>0;y--)
         ;
}

void INITSCON(void) //串口初始化
{
     TMOD=0x20;
     PCON=0x00;
     TH1=0xfd;
     TL1=0xfd;
     SCON=0x50;
     TR1=1;
         EA=1;
         ES=1;
          
}
/*************************************************************/
/****************      主函数    *****************************/
/*************************************************************/
main()
{
   //uchar s;
   delay(5000);
   INITSCON();
   while(1)
   {
          
        }
}

void receive_uart() interrupt 4          using 2//接收中断服务函数
{
  while(RI==1)
  {         
    RI=0;
    if(cou_rec==30)
      cou_rec=0;
           date_rec[cou_rec]=SBUF;

     cou_rec++;

   }
  if(date_rec==RING)         //        接收到振铃信号让继电器吸合
        {   
                  i++;
             if(i==4)
             {
               i=0;
                   jdq1=0;
               jdq2=0;
              }
         }         

}


[attach]3044[/attach]







欢迎光临 中科因仑“3+1”工程特种兵精英论坛 (http://bbs.enlern.com/) Powered by Discuz! X3.4