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

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

   adaizhu 
adaizhu发表的帖子 

 为什么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();
}



发表时间:2004年7月20日13:20:02

  
回复该帖

本主题共有 2 帖,分页:>>>>>该主题的所有内容[2]条

 *树形目录 只列出部分跟帖的标题以及简单的摘要信息 该主题的部分跟帖如下:

  58547.[详细]奇怪,我烧进片子可以正常发数,用KEIL模拟仿真器缺怎么也经不了串口中断..
摘要:......(无内容)
- [adaizhu][1337次] 2004年7月20日

[上一篇帖子]:[quote][b]以下是引用[i]一休在2003-1-11 23:12:00[/i]的发
[下一篇帖子]:有谁在C51里面使用过goto语句到绝对地址的?我想在C51里面加上一句类似 goto&n