Documentation sections
UART Baud Rate & Frame Timing Calculator
POSThttps://rftools.io/ api/ py/ v1/ calculate
Slug uart-baud-rate. Calculate UART frame timing, throughput, and USART BRR register divisor from baud rate, data format, and MCU clock frequency. Identify baud rate error for reliable serial communication.
Inputs
Send every one of these in inputs, in the units shown. Most are required: a call without one is refused (400) and costs nothing; one the calculator can do without takes the default shown. An input outside its range is still computed and flagged in the provenance.
| Name | Unit | Range | Default | Description |
|---|---|---|---|---|
| baudRatenumber | bps | 300 … 4000000 | 115200 | Serial baud rate in bits per second |
| dataBitsnumber | bits | 5 … 9 | 8 | Number of data bits per frame (typically 8) |
| stopBitsnumber | bits | 1 … 2 | 1 | 1 stop bit is standard; 2 may be used for slow receivers |
| paritynumber | bits | 0 … 2 | 0 | Parity Bits |
| clockFreqnumber | MHz | 1 … 1000 | 16 | MCU peripheral (APB) clock frequency used for BRR divisor calculation |
| oversamplingnumber | none | 8 … 16 | 16 | Samples per bit: 16× is the usual mode; 8× (STM32 OVER8, AVR U2X) doubles the fastest rate at the cost of noise immunity |
| divisorFractionnumber | none | 0 … 1 | 0 | A whole divisor (AVR UBRR, the 16550) or one with a fraction of 1/OS (STM32 USARTDIV), which comes far closer to most rates |
| errorBudgetnumber | % | 0.1 … 10 | 2 | The baud-rate error the link can take, ± both ends together; about ±2 % for 16× oversampling and 8N1 frames |
Outputs
Returned in values, by key. A value that is unbounded or undefined is null.
| Field | Unit | Description |
|---|---|---|
| frameBits | bits | 1 start + data bits + parity + stop bits |
| bitPeriod_us | µs | Bit Period |
| framePeriod_us | µs | Frame Period |
| framesPerSecond | fps | Frames per Second |
| throughputKbps | kbps | Effective data rate (data bits only, not overhead) |
| brrDivisor | none | The clock over the oversampling rate times the baud rate, before rounding |
| actualBaudRate | bps | Baud rate achieved with the divisor as set |
| baudRateError_pctheadline | % | Deviation of actual from target baud rate; keep below 2% for reliable operation |
| divisorSet | none | The divisor the register holds: whole, or in steps of 1/OS |
| baudError_pct | % | Actual over target, signed: negative when the actual rate is slower |
| stopSampleOffset_bits | bits | How far from the stop bit's centre a receiver at the actual rate samples a frame sent at the target rate; positive is late |
Calling it
- Calculate: one call, the request and response in full, and its errors.
- Batch: this calculator with others, or a sweep, in one request.
- Solve for a target: the value of one input that brings an output to a target.