Calculate a UART baud rate divisor
calc_uart_baudComputes the divisor for a UART baud rate from the peripheral clock, with the real baud rate and its error in percent, and the BRR value for STM32. Use it to set a baud rate or to find out why a link shows framing errors or garbage. The peripheral generic fits any UART that divides its clock by a whole number, with 16 or 8 samples a bit. For the STM32 USART and LPUART it also gives the BRR value.
Tool call template
Replace each placeholder with a value matching the input schema. Only required parameters are included; add optional parameters as needed.
{
"id": 1,
"jsonrpc": "2.0",
"method": "tools/call",
"params": {
"arguments": {
"peripheral": "<peripheral>",
"clock_hz": "<clock_hz>",
"baud": "<baud>"
},
"name": "calc_uart_baud"
}
}Input Schema
| Name | Required | Description | Default |
|---|---|---|---|
| baud | Yes | The baud rate, for example 115200. | |
| clock_hz | Yes | The clock of the UART in Hz. | |
| peripheral | Yes | generic, stm32-usart or stm32-lpuart. | |
| oversampling | No | Samples per bit, 16 or 8. Default 16. The LPUART ignores it. |