Actually the code behaves strangely I receive only the first byte and the OVERRUN bit is set !
OVERRUN occurs when data is coming in faster than it is being read out of the UART. It could be caused by mismatched baud rates/word size/polarity etc., excessive processing overhead, or noise on the rx line. You may get an initial overrun if the other end starts sending data before the receiver is ready.
However, getsUSART() reads the UART in a tight loop until it has received the specified number of bytes, even if errors occur. So I am curious as to how you know that the OVERRUN error occurs on the first byte?
I'm configuring the USART of the two controllers with the same code so they should have the baudrate !
Here is my Configuration:
Thanks for that. The config looks correct, however this is just another fragment of your code and the rest is still a mystery to us. Did you put USE_OR_MASKS
before including uart.h, are any peripherals generating interrupts that might interfere with UART reception, or is some other part of your code causing the problem? You could clear up this mystery by posting
all the code required to reproduce the error (you can strip out anything you don't think is relevant, so long as the UART receive part still functions). It might also be useful to see the transmitting MCU's code.
I realized a mistake in the PIC datasheet ... It says that I should set TRISC0 to 1 !!
You must have an older version of the datasheet. Download the latest version from
http://www.microchip.com/wwwproducts/Devices.aspx?product=PIC18F4431.