by AussieSusan » Thu Jan 22, 2026 3:10 am
There is a reason I asked for the config register settings.
For the PIC16F690, your setting of OSCCON to 0x01110000 has the SCS bit set to 0 which says that the clock source is set by FOSC but you don't show that setting. Assuming that you really do have an 8MHz clock, then using Table 12-1 of the data sheet, I get a baud rate of 27,778. Looking at the 3rd part of Table 12-3 which matches your values for SYNC, BRGH and BRG16, then for 8MHz, the SPBRG value should be 51. In general, the Microchip UARTs need to be initialised strictly in the order they describe in the data sheet - in this case sections 12.3.1 and 12.3.2
For the PIC16F18877, you don't show anything about the clock speed but given your (slightly ambiguous) statement in the original post, I assume that you have an 8MHz clock there as well. If so then your baud rate calculation is way off. Even taking the Example 33-1 and using halving their Fosc, you should have a SPBRG value closer to 12. As above, the initialisation sections are 33.1.1 and 33.1.2.8.
Your example includes a number of lines that set the timers - these are totally irrelevant for the UARTs.
At this stage I would also NOT play with interrupts - get the basic functionality working first with blocking code and then add in the complexities of interrupts later on (if needed at all).
(By the way - at this stage you don't need to define _XTAL_FREQ as you are not using any compiler-defined delay functions.)