UART Recieve Code

Status
Not open for further replies.

Suraj143

Active Member
Guys I need to detect FERR & OERR happen in the UART module in PIC.

If these errors happens will the PIC generates interrupts? Because inside ISR I check those errors after RCIF = 1.

Is my code ok?

Code:
Check_UART	btfss	PIR1,RCIF		; Is it a Recieve interrupt?
		goto	ISR_Exit
Check_Errors	movf	RCSTA,W
		andlw	b'00000110'
		btfsc	STATUS,Z
		goto	Read_UART
;--------------------------------------------------------------------------------------
Clear_OERR	bcf	RCSTA,CREN
		nop
		bsf	RCSTA,CREN
		;
Clear_FERR	movf	RCREG,W
		movf	RCREG,W
		movf	RCREG,W
		goto	Reset_Field
;--------------------------------------------------------------------------------------
Read_UART	movf	RCREG,W			; read the buffer
		andlw	b'01111111'
		movwf	RX_DATA			; load to a temperory register
 
Just clearing and setting the CREN reboots the USART so that is all that is needed..

You really shouldn't Double Post.....
 
Ok thanks.That means even UART module gets stucked with buffer it still generates interrupts ...!!!
 
Status
Not open for further replies.
Cookies are required to use this site. You must accept them to continue using the site. Learn more…