Serial communication only once?


Closed Thread
Results 1 to 4 of 4
  1. #1
    Join Date
    Jul 2011
    Posts
    14

    Default Serial communication only once?

    Hi,

    I wrote the following code:

    Code:
    Main:
        HIGH LED_RED
        LOW LED_GREEN
        pause 500
        
        ;Common setup
        SPBRG = 129 ;Baud rate 9600
        TXSTA.2 = 1 ;BRGH for hight speed
        TXSTA.4 = 0 ;USART coomunication
        RCSTA.7 = 1 ;Serial enable
        ;Tx setup
        PIE1.4 = 0  ;
        TXSTA.6 = 0 ;8 bit
        ;Rx setup
        PIE1.5 = 1  
        RCSTA.6 = 0
        RCSTA.4 = 1
        RCSTA.2 = 0
        RCSTA.1 = 0
        
        HIGH LED_GREEN
        LOW LED_RED 
    Ever:
        ;BUTTON switch, 1, 0, 100, button_count, 1, Rx_command
        Hserout ["I wait"]
        hserin [WAIT("MR")]
        HIGH LED_RED
        PAUSE 500
        low LED_RED
        GOTO Ever
    The first time posting on the serial "MR,00,0000,CR" works fine, but then the second time does not work anymore. Advise anyone know any solution?

  2. #2
    Join Date
    Sep 2004
    Location
    montreal, canada
    Posts
    6,898


    Did you find this post helpful? Yes | No

    Default Re: Serial communication only once?

    add
    Code:
    DEFINE HSER_CLROERR 1
    at the top of your code
    Steve

    It's not a bug, it's a random feature.
    There's no problem, only learning opportunities.

  3. #3
    Join Date
    Nov 2003
    Location
    Wellton, U.S.A.
    Posts
    5,924


    Did you find this post helpful? Yes | No

    Default Re: Serial communication only once?

    Put this in the "Ever" loop
    RCSTA.4 = 0 : RCSTA.4 = 1
    Dave
    Always wear safety glasses while programming.

  4. #4
    Join Date
    Sep 2004
    Location
    montreal, canada
    Posts
    6,898


    Did you find this post helpful? Yes | No

    Default Re: Serial communication only once?

    This is somehow what the define will do, except it will test if there's any error, if so it will clear them

    from the .LIB
    Code:
          ifdef HSER_CLROERR
        btfsc    RCSTA, OERR    ; Check for overflow error
        bcf    RCSTA, CREN    ; Toggle continuous receive to clear error
        bsf    RCSTA, CREN
          endif
    Steve

    It's not a bug, it's a random feature.
    There's no problem, only learning opportunities.

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