View Full Version : Framing Error /w USART
DynamoBen
- 26th February 2007, 17:41
I have an application where I need to collect data after a framing error has occurred. What I've found so far is I have to be reading the port via HSERIN to sense a framing error. Is there any way to sense a framing error without needing to read RCREG or HSERIN?
I'm assuming not but I thought I would ask to save some time.
Darrel Taylor
- 27th February 2007, 01:01
Hi Ben,
The only problem is that if you don't read RCREG, the USART will stop after receiving 2 bytes. Then it'll never see a framing error.
A very simple interrupt routine could solve that though.
Just a quick example...
CREN VAR RCSTA.4
FERR VAR RCSTA.2
OERR VAR RCSTA.1
RCIE VAR PIE1.5
Dummy VAR BYTE
ON INTERRUPT GOTO USART_Handler
RCIE = 1 ; Enable USART RX INTs
Main:
IF FERR THEN
FERR = 0
TOGGLE LED ; Do something here
ENDIF
GOTO Main
DISABLE
USART_Handler:
IF OERR then ; Clear Overrun Errors
CREN = 0
CREN = 1
ENDIF
Dummy = RCREG ; Empty USART Buffer and Clear RCIF
RESUME
ENABLE
HTH,
DynamoBen
- 27th February 2007, 01:34
Another case of I want what I can't have. ;) Just trying to keep the code tight. I actually have a similar routine I guess thats the method I'm sticking with. Thanks!
Powered by vBulletin® Version 4.1.7 Copyright © 2025 vBulletin Solutions, Inc. All rights reserved.