Serial monitor is unreadable at higher baud rates

The integrated serial monitor isn’t able to read at higher baud rates. Yes, I am updating the monitor_speed flag in platformio.ini

This code:

Serial.begin(9600); 
Serial.print("PIP_0_SWEEP_MIN = ");
Serial.println(PIP_0_SWEEP_MIN);
Serial.print("PIP_0_SWEEP_MAX = ");
Serial.println(PIP_0_SWEEP_MAX);
Serial.print("PIP_1_SWEEP_MIN = ");
Serial.println(PIP_1_SWEEP_MIN);
Serial.print("PIP_1_SWEEP_MAX = ");
Serial.println(PIP_1_SWEEP_MAX);

Provides proper output:

PIP_0_SWEEP_MIN = 1781
PIP_0_SWEEP_MAX = 2538
PIP_1_SWEEP_MIN = 1767
PIP_1_SWEEP_MAX = 2498

While this code:

Serial.begin(230400); 
Serial.print("PIP_0_SWEEP_MIN = ");
Serial.println(PIP_0_SWEEP_MIN);
Serial.print("PIP_0_SWEEP_MAX = ");
Serial.println(PIP_0_SWEEP_MAX);
Serial.print("PIP_1_SWEEP_MIN = ");
Serial.println(PIP_1_SWEEP_MIN);
Serial.print("PIP_1_SWEEP_MAX = ");
Serial.println(PIP_1_SWEEP_MAX);  

Outputs unreadable data:

�2�a�ʵ��u��ꀬ␓ʍ!U��z���␔���␅�Fs�!U������1���
ꀌ�ڍ!U������1���␅�␆3�

A baud rate of 230.4 kb/s is necessary for the project.

You didn’t even say what your board was. No full platformio.ini given. No details about microcontroller or clock frequency.

There are two sides to the equation: Your microcontroller and the USB-to-UART receiver. If your microcontroller can’t generate a clock for 230400 baud within the tolerances of the UART protocol, you’re gonna get garbage. E.g., an Arduino Uno at f_CLK = 16MHz cannot reliably use 230400 baud because it cannot divide its clock to that number with acceptable error (8.5% error, yikes!). But, 250000 baud would be a 0% error because it finds 16MHz / 64 = 0.250 MHz cleanly.

(from http://wormfood.net/avrbaudcalc.php)

Again, since you have given 0 details about your microcontroller, we can’t say anything certain.

My apologies for the poor initial post. It was written in a sleep-deprived and frustrated stupor.

I am using the Arduino Due (sam3x8e processor). MCLK is running at 84 MHz. Here is my platfomio.ini:

[env:due]
platform = atmelsam
board = due
framework = arduino
lib_deps=
  pololu/LSM6@^2.0.1
  pololu/LIS3MDL@^2.0.0
  janelia-arduino/Vector@1.2.2
monitor_speed = 9600
; debugging flags - make sure you adjust ports as necessary:
;debug_tool = blackmagic
;upload_protocol = blackmagic
;upload_port = COM5
;build_type = debug
;debug_init_break = tbreak setup
;monitor_port = COM4

The commented flags at the bottom are uncommented when I am using the Black Magic probe for upload and debugging. I have the same issue with them commented or uncommented.

I am a bit confused about the table you sent, as I am somewhat new to embedded systems. What is the relationship between the clock speed, baud rate, and error? My understanding of the UART peripheral is that the data is simply loaded into a buffer, and the peripheral device handles sending the data out at the given baud rate. Would the initial loading of data into the buffer not be accomplished in one or two clock cycles, making the relationship between clock speed and baud rate irrelevant?

In other words, your ATMega16U2, which has a 16 MHz crystal, is your UART receiver that sends it to USB. Yeah, then see above, that’s a game over right there. Change it to 250,000 baud, which is more favourable to your poor 16MHz ATMega16u2, it should receive that fine.

https://www.arduino.cc/en/uploads/Main/arduino-Due-schematic.pdf