chipKIT32/chipKIT32-MAX — Issue #181: Support higher baud rates on hardware serial port
Author: EmbeddedMan
Created: 2012-01-07 18:20:38+00:00
State: open

In p32_defs.h, add the following line:

#define _UARTMODE_BRGH 3

right under

#define _UARTMODE_ON 15

And then in HardwareSerial.cpp replace

uart->uxBrg.reg = ((__PIC32_pbClk / 16 / baudRate) - 1);	// calculate actual BAUD generate value.
uart->uxSta.reg = 0;
uart->uxMode.reg = (1 << _UARTMODE_ON);	//enable UART module
uart->uxSta.reg = (1 << _UARTSTA_UTXEN) + (1 << _UARTSTA_URXEN);	//enable transmitter and receiver

with

uart->uxSta.reg = 0;
if (baudRate < 200000)
{
uart->uxBrg.reg	= ((__PIC32_pbClk / 16 / baudRate) - 1);	// calculate actual BAUD generate value.
uart->uxMode.reg = (1 << _UARTMODE_ON);	//enable UART module
}
else
{
uart->uxBrg.reg	= ((__PIC32_pbClk / 4 / baudRate) - 1);	// calculate actual BAUD generate value.
uart->uxMode.reg = (1 << _UARTMODE_ON) | (1 << _UARTMODE_BRGH);	//enable UART module
}
uart->uxSta.reg = (1 << _UARTSTA_UTXEN) + (1 << _UARTSTA_URXEN);	//enable transmitter and receiver

Note, I'm not sure about the value 200000 - I just kinda guessed at that.

If you do that, you'll have no trouble getting the highest supported baud rate of the FTDI chip - 921600.

*Brian