Framing Error /w USART


Closed Thread
Results 1 to 3 of 3
  1. #1
    Join Date
    Jun 2005
    Location
    Wisconsin
    Posts
    382

    Default Framing Error /w USART

    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.

  2. #2
    Join Date
    Jul 2003
    Location
    Colorado Springs
    Posts
    4,959


    Did you find this post helpful? Yes | No

    Default

    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...
    Code:
    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,
    DT

  3. #3
    Join Date
    Jun 2005
    Location
    Wisconsin
    Posts
    382


    Did you find this post helpful? Yes | No

    Default

    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!

Similar Threads

  1. problem with USART
    By leemin in forum Serial
    Replies: 4
    Last Post: - 11th December 2006, 17:56
  2. I ammm Looosssst (USART Help)
    By shawn in forum mel PIC BASIC Pro
    Replies: 5
    Last Post: - 16th May 2006, 05:05
  3. USART interrupt not interrupting right
    By Morpheus in forum mel PIC BASIC Pro
    Replies: 12
    Last Post: - 6th March 2005, 01:07
  4. Clearing Framing Errors
    By EShatara in forum mel PIC BASIC Pro
    Replies: 14
    Last Post: - 3rd December 2004, 00:33
  5. Replies: 5
    Last Post: - 1st December 2004, 12:49

Members who have read this thread : 0

You do not have permission to view the list of names.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts