U2BRG seemingly ignored. Wrong UART transmit baud rate.
I'm trying to debug a specific piece of code so I'm implementing some blocking polled UART transmit functionality that ensures that a debug string has completely transmitted before the next line of code is executed. Unfortunately I can't seem to be able to get the U2BRG register to do what I want. I have a logic analyzer on the transmit line and I see my debug characters formatted as if U2BRG was set to 0. My code sets it to 25, and using a PICkit 4, MPLABx tells me that the value is 25, but the transmitted bytes appear as if the UART peripheral is using 0. I changed the BRGH value from 1 to 0 and noticed a 4-times increase in my character times (4 times baud rate decrease) so some part of my initialization code is doing something. Can anybody spot anything that I'm overlooking? FYI, using a 24MHz clock; UART peripheral clocked at 12MHz, and I'm aiming for 115200. Thank you.
At 115200, 8-bit character plus 1 start-bit should be about 78us; I'm seeing 3us on the logic analyzer.
void blDebugInit(/*uint16_t brgVal, uint8_t brgHval*/void)
U2MODE = 0;
U2MODEbits.BRGH = 1; // high baud rate
U2BRG = 25; // BAUD Rate Setting
U2MODEbits.RTSMD = 1; // No flow control mode
U2MODEbits.UARTEN = 1; // UART is Enabled
U2STAbits.UTXEN = 1; // transmit is enabled
for (i = 0; i < 5000; i++)