yasser_shoukry
Full Member level 4
- Joined
- May 31, 2006
- Messages
- 233
- Helped
- 25
- Reputation
- 54
- Reaction score
- 5
- Trophy points
- 1,298
- Location
- Cairo - Egypt
- Activity points
- 2,749
pic18f uart
Hi all,
I am facing a problem with the UART of my PIC18F4580 module as the RCIF (receive interrupt flag) never goes down after the first receiving byte. The data sheet says that to clear this bit , I should read RCREG (receive register) , I did so but nothing happens.
Note:- I am using MPLAB SIM to test the UART functionality
Here is the part of the interrupt service routine which handles the UART receiving part.
Can any body help me,
Thanks in advance
Hi all,
I am facing a problem with the UART of my PIC18F4580 module as the RCIF (receive interrupt flag) never goes down after the first receiving byte. The data sheet says that to clear this bit , I should read RCREG (receive register) , I did so but nothing happens.
Note:- I am using MPLAB SIM to test the UART functionality
Here is the part of the interrupt service routine which handles the UART receiving part.
Code:
if( PIR1bits.RCIF == 1){
byteReceieved = RCREG;
if(RCSTAbits.OERR == 1){ //Start with error handling (Overrun error)
TXSTAbits.TXEN=0;
TXSTAbits.TXEN=1;
RCSTAbits.CREN=0;
RCSTAbits.CREN=1;
}
else if(RCSTAbits.FERR == 1){ //Handling Framing error
char dummy;
dummy = RCREG;
TXSTAbits.TXEN=0;
TXSTAbits.TXEN=1;
}
else{ //If message is recieved correctly then process this data
USART_Receive(byteReceieved);
}
Can any body help me,
Thanks in advance