RCSTA1 issue?


Closed Thread
Results 1 to 10 of 10

Thread: RCSTA1 issue?

Hybrid View

  1. #1
    Join Date
    Oct 2005
    Location
    New Jersey
    Posts
    425


    Did you find this post helpful? Yes | No

    Default Re: RCSTA1 issue?

    As far as I know DEFINE HSER_CLROERR 1 (for the second USART it's DEFINE HSER2_CLROERR 1) is available in PBP2.x as well. But, remember that it only "works" when you're actually using HSERIN, if you "drive" the USART manually (like when you do DAT_IN1 = RCREG1) it won't do anything and you'd need to check/clear the overrun flag manually. It all it does is clear the overrun error flag (if set), it won't do anything to actually prevent the overrun condition in first place.
    Overruns aren't really a problem, except when that condition locks up the device. More importantly, you pointed out something I never caught onto. So there is a HSER@2_CLOERR 1 define.
    The main issue here is most likely the overall structure of the program. The data needs to be read from the USART buffer before the next byte comes in, the "best" way to handle this (if you don't know when data is about to come in) is usually to use interrupts. I don't know how you're handling it in your program (I may have missed it).
    I use HSERIN/HSERIN2 to get all data and I use interrupts to get it. If I understand your post correctly, I can remove this:
    Code:
    IF RCSTA1.1 = 1 THEN    
           RCSTA1.4 = 0          
           RCSTA1.4 = 1
           DAT_IN1 = RCREG1         
           IF PIR1.5 = 1 THEN DAT_IN1 = RCREG1  
        ENDIF
    And just use this:
    Code:
    DEFINE HSER_CLROERR 1
    Is that correct?

  2. #2
    Join Date
    Oct 2005
    Location
    Sweden
    Posts
    3,612


    Did you find this post helpful? Yes | No

    Default Re: RCSTA1 issue?

    Hi Christopher,
    Yes I believe that's correct. I Think what that define does is add code "in front" of the actual HSERIN code so that it checks the overrun flag and, if set, takes care of it.

    /Henrik.

Similar Threads

  1. IF-THEN issue
    By jmgelba in forum mel PIC BASIC Pro
    Replies: 5
    Last Post: - 12th February 2014, 22:09
  2. TMR1 issue
    By Lestat in forum General
    Replies: 6
    Last Post: - 29th August 2012, 15:41
  3. Timing issue
    By gadelhas in forum mel PIC BASIC Pro
    Replies: 9
    Last Post: - 29th November 2011, 14:13
  4. Code Issue - select case or 'if' issue - not sure why
    By jamie_s in forum mel PIC BASIC Pro
    Replies: 2
    Last Post: - 7th October 2007, 08:52
  5. 16F877A issue
    By DynamoBen in forum Off Topic
    Replies: 9
    Last Post: - 31st August 2007, 04:15

Members who have read this thread : 1

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