Quote Originally Posted by talatsahim View Post
can you help me why not work my code?
Yes I can ...
  1. HSER defines only work with HSERIN/HSEROUT. If you are reading RCREG manually, the baud rate will not have been set by PBP and you will have to do that manually as well.<br><br>
  2. pulsin RXT,0,BREAKTIME, PULSIN does not work with interrupts. The timing will be wrong and you'll almost never see a Break pulse that way. Fortunately, the USART does it for you. Look for an FERR flag (framing error) which happens on every Break.<br><br>
  3. INTCON =%11000000, interrupts are controlled by the MIBAM routines. Don't change any interrupt registers.<br><br>
  4. PIE1.5=1, you've enabled the USART receive Interrupt ... don't do that.<br><br>
  5. RCREG = dummy, RCREG is a Read-Only register. Don't know what you were trying to do there.<br><br>
  6. SPBRG = 0, it's unlikely that you would want to put SPBRG (Baud Rate Generator Register) to 0 for any reason.<br><br>
  7. TXSTA.2 = 0, It's unlikely that you would want to put the USART in Low Speed mode when running at 250Kbaud.<br><br>
  8. TXSTA.4 = 0, OK, it's not synchronous mode .... but what is it?<br><br>
  9. I have no idea what you are trying to do here. RCREG is read-only, and you're reading 3-bytes from a maximum 2-byte buffer, without checking to see if anything is there.
    Code:
    DATAAL:
    RVAL= RCREG 
    RCREG = 0 
    RCREG = 0 
    GVAL= RCREG 
    RCREG = 0 
    RCREG = 0 
    BVAL= RCREG 
    ENDIF
    RCSTA.7 = 0 
    DMXFLAG=1
    return

Back to the Drawing Board.