I am currently using the PIC24 with UART and am able to receive (Rx) and transmit (Tx) characters. The problem arises when trying to receive a continuous stream of characters, where there is no delay between start and stop bits.
The UART is setup with; 7 data bits, 1 parity bit and 1 stop bit at 1200baud
When displaying the received characters on a terminal it shows that only certain characters will print correctly. I do not believe this to be a baud rate error as I am able to receive and print characters correctly when small delay between start and stop bits i.e holding down a key on a keyboard.
To read two characters that were sent continuously I am doing as follows.
char buf[512];
while (U2STAbits.URXDA == 0); //wait while Rx buffer is full
buf[0] = U2RXREG;
while (U2STAbits.URXDA == 0); //wait while Rx buffer is full
buf[1] = U2RXREG;
while (U2STAbits.UTXBF); //wait while Tx Bit not free
U2TXREG = buf[0];
while (U2STAbits.UTXBF); //wait while Tx Bit not free
U2TXREG = buf[1];
There might be other problems which we can't see since you just gave us only a small portion of your code.
Anyway, with the additional information in your comment, it's a mismatch in the parity:
Characters received fine:
Characters not received:
Please, the next time, instead of putting additional information in a comment, edit your question. That way all visitors have all the bits together without having to wade through all the comments.