英锐恩单片机论坛,Microchip单片机,模拟器件,接口电路,麦肯单片机,单片机应用交流

 找回密码
 立即注册
搜索
电子烟方案单片机单片机开发深圳单片机开发
单片机方案国产单片机8位单片机电子烟方案开发
查看: 3614|回复: 1
打印 上一主题 下一主题

用了C18的编译器,中断为什么会出错

[复制链接]
跳转到指定楼层
1#
发表于 2009-4-26 11:35:39 | 只看该作者 回帖奖励 |倒序浏览 |阅读模式
void interrupt USART(void)

{
  unsigned char data,tmphead,tmptail;
/*
  if((TMR1IF) && (TMR1IE))
   {
  TMR1H = 0x80;
  TMR1IF = 0;
     if(60 == ++secs)
      {
   secs = 0;
    ++mins;
   }
  if(60 == mins)
   {
   mins = 0;
   ++hours;
   }
  if(24 == hours)
   {
      hours = 0;
   }
}
*/
  if((TMR2IF) && (TMR2IE))
   {
  TMR2IF = 0;
        ++msecs_timer;
   }
  if(RC1IF)
{
  LATD0 = 1;
   data = RCREG1;                   // read the received data
                                // calculate buffer index
   tmphead = ( USART_RxHead + 1 ) & USART_RX_BUFFER_MASK;
   USART_RxHead = tmphead;        // store new index
   if ( tmphead == USART_RxTail )
   {
     // ERROR! Receive buffer overflow
   }
                                
   USART_RxBuf[tmphead] = data;   // store received data in buffer
  }

  if(TRMT)
  {
                                // check if all data is transmitted  
   if ( USART_TxHead != USART_TxTail )
   {
                                // calculate buffer index  
     tmptail = ( USART_TxTail + 1 ) & USART_TX_BUFFER_MASK;
     USART_TxTail = tmptail;      // store new index  
    TXREG1 = USART_TxBuf[tmptail];  // start transmition  
   }
   else
   {
     TX1IE = 0;         // disable TX interrupt  
   }
  }
}

Clean: Deleting intermediary and output files.
Clean: Done.
Executing: "C:\mcc18\bin\mcc18.exe" -p=18F4520  /i"C:\mcc18\h" "enc_driver.c" -fo="enc_driver.o" -Ou- -Ot- -Ob- -Op- -Or- -Od- -Opa-
MPLAB C18 v3.02 (demo)
Copyright 1999-2005 Microchip Technology Inc.
Days remaining until demo becomes feature limited:  39
E:\myprogram\28dr\enc_driver.c:1399:Error: syntax error
Halting build on first failure as requested.
BUILD FAILED: Sun Sep 10 22:40:54 2006
2#
 楼主| 发表于 2009-4-26 11:35:48 | 只看该作者
C18里不能直接写TMR1IF的,看看.h文件,写成PIR1bits.TMR1IF
回复 支持 反对

使用道具 举报

您需要登录后才可以回帖 登录 | 立即注册

本版积分规则

关闭

站长推荐上一条 /1 下一条

小黑屋|公司首页|Microchip单片机,模拟器件,接口电路,麦肯单片机,单片机应用交流 ( 粤ICP备09008620号 )

GMT+8, 2024-5-2 11:02 , Processed in 0.050801 second(s), 22 queries .

Powered by Discuz! X3.2

© 2001-2013 Comsenz Inc.

快速回复 返回顶部 返回列表