导航: 老古网老古论坛XMOS公共讨论区XMOS开源项目区单片机程序设计嵌入式系统广告区域
→为什么w77e58进不了串口1发送中断子程序?[求助][adaizhu]

 *第23907篇: 为什么w77e58进不了串口1发送中断子程序?[求助]

  
楼 主:adaizhu 2004年7月20日13:20
 为什么w77e58进不了串口1发送中断子程序?[求助]
void SendStart(void)
{/*启动发送*/
 if (sendlen >   0)
    {
     sendpoint = 0;
     SBUF1 = sendbuf[sendpoint++];
    }
  /*等待发送完毕*/
  sendfull = 0;
  while(sendfull==0)  _nop_();
}

void adjust_time(void)
{
 uchar i,ucTemp;
 sendbuf[0]=0xff;         /*帧起始字节*/
 sendbuf[1]=0x10;         /*命令*/
 sendbuf[2]=0x05;         /*数据长度*/
 sendbuf[9]=0x0d;         /*帧结束字节*/
 sendbuf[3]=0;//GetMonth();   /*月*/
 sendbuf[4]=0;//GetDay();     /*日*/
 sendbuf[5]=0;//GetHour();    /*时*/
 sendbuf[6]=0;//GetMinute();  /*分*/
 sendbuf[7]=0;//GetSecond();  /*秒*/

 for(ucTemp=sendbuf[1],i=2;i  <8;i++) /*计算校验和*/
     ucTemp+=sendbuf[i];
 sendbuf[8]=(~ucTemp)+1;

 sendlen=10;
 SendStart();
}

void sio1() interrupt 7 using 2        /*串口1中断--DR & PC*/
{
 xdata uchar ucXor,i;
       if (_testbit_(TI))
         {  //发送数据
            if (sendfull==0 && sendpoint  <sendlen)
               {
                SBUF1  = sendbuf[sendpoint++];
               }
            else
              sendfull==1;  
          }       
 }   
void ini_mcu(void)
{
  PMR   = 0x40;     //4 clocks/machine cycles , switch disable , ALE enable , 
internal 1K SRAM disable , oscilator enable
  DPS   = 0x00;     //DPTR is selected
  CKCON = 0xc1;   //clock of Timer0,1,2 is divided by 12 ,others default
  WDCON = 0x00;   //disable wathcdog reset
  EIE   = 0x00;     //disable watchdog interrupt and extern2-5 interrupt
  EIP   = 0x00;     //all extended interrupt priority disable
  T2MOD = 0xf0;   //EXTN2,3,4,5 flag auto clear,T2 down counter disable
  T2CON = 0x00;   //Timer1 act as  baudrater
  SCON1 = 0X50;
  TMOD  = 0x20;  //start Timer0 ,1ms interrupt
  TH1   = 0xFA;
  TL1   = 0xFA;
 
  TR1   = 1;
  ES1    = 1;  //enable serial port interrupt
  ET1    = 0;
  EA    = 1;            //first enable all interrupt
}

void main(void)
{ini_mcu();
adjust_time();
}

  
2楼:adaizhu 2004年7月20日13:43
 奇怪,我烧进片子可以正常发数,用KEIL模拟仿真器缺怎么也经不了串口中断

>>>>>>对该主题发表你的看法

本主题贴数2,分页: [第1页]


[上一篇主题]:谁有《开关、电机、电缆标准》光盘,请EMAIL

[下一篇主题]:有谁在C51里面使用过goto语句到绝对地址的?