I'm using a PIC16F18326 to transmit some data over UART (asynchronous, 250k baud rate). The MCU runs at 32MHz, with an actual instruction frequency of 8MHz.
I'm using the following assembly code to send 4 bytes (from 0xAA to 0xAD - don't mind the useless repeated BANKMASK):
movlw 0xAA
banksel TX1REG
movwf BANKMASK(TX1REG)
movlw 0xAB
banksel TX1REG
movwf BANKMASK(TX1REG)
movlw 0xAC
banksel TX1REG
movwf BANKMASK(TX1REG)
movlw 0xAD
banksel TX1REG
movwf BANKMASK(TX1REG)
goto $
The result from the logic analyzer is that only 0xAA and 0xAD have been sent (first and last byte).
I know that I can't send 4 bytes back-to-back (without any delay, or some checks of the UART registers), but I would have expected to send 0xAA and 0xAB (the first 2 bytes).
According to the datasheet, if TX1REG and TSR registers are empty (which is my case since I have never transmitted anything), I can write to TX1REG to start the send of the first byte, and then after at least 1 clock cycle I can queue up the second byte. According to the code below, there are 3 clock cycles between the 2 writes.
So, what is going wrong?
Have a look at page 367 of this about the list of features:
The problem you are experiencing acts just like a buffer overrun. If this is about the correct USART, then you are getting just would be expected.
A more general purpose bit of software would be useful to loop for each character and await the "buffer ready bit" (or whatever it is called) before loading the buffer with the next character.