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

标题: 用了C18的编译器,中断为什么会出错 [打印本页]

作者: winnie    时间: 2009-4-26 11:35
标题: 用了C18的编译器,中断为什么会出错
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
作者: winnie    时间: 2009-4-26 11:35
C18里不能直接写TMR1IF的,看看.h文件,写成PIR1bits.TMR1IF




欢迎光临 英锐恩单片机论坛,Microchip单片机,模拟器件,接口电路,麦肯单片机,单片机应用交流 (http://www.enroobbs.com/) Powered by Discuz! X3.2