Re: PIC18F_USART_RX問題(用C18)
|
||||
---|---|---|---|---|
初級會員
|
感謝 master 前輩指導,剛試驗成功。
正在瞭解這種寫法。並從中瞭解自己錯在哪。 非常謝謝前輩指導
發表於: 2008/10/17 10:49
|
|||
|
PIC18F_USART_RX問題(用C18)
|
||||
---|---|---|---|---|
初級會員
|
再次請教版上前輩問題,關於USART的RX問題。
傳送端會丟來3個BYTE(0xFF,0x55,0xAA) 我想判定第二個byte的資料,是否為0x55 可是我用下列寫法。我看我的PORTB會顯示出三種狀態。 想請教我在接收RX的資料做判別。是否有寫錯之處? ----------------------------------------------------------------- #include <p18f2321.h> #include <delays.h> #include <adc.h> #include <timers.h> #include <usart.h> #pragma config OSC=HS, BOR=OFF, BORV=2, PWRT=ON, WDT=OFF, LVP=OFF struct Flag { unsigned TXD:1; }FLAGbits; void Rx_isr (void); #pragma code low_vector=0x18 void low_interrupt (void) { _asm GOTO Rx_isr _endasm } #pragma code #pragma interruptlow Rx_isr void Rx_isr (void) { unsigned char RX_Temp[7]; unsigned char i; PIR1bits.RCIF = 0; for(i=0;i<3;i++) { RX_Temp[i]=ReadUSART(); } PIR1bits.RCIF = 0; PORTB = RX_Temp[1]; } void main () { PORTB = 0x00; TRISB = 0; OpenUSART( USART_TX_INT_OFF & USART_RX_INT_ON & USART_ASYNCH_MODE & USART_EIGHT_BIT & USART_CONT_RX & USART_BRGH_HIGH, 12 ); RCONbits.IPEN=1; INTCONbits.GIEL = 1; INTCONbits.GIEH = 1; FLAGbits.TXD=0; while(1) { } }
發表於: 2008/10/16 16:27
|
|||
|