Calculate timer prescaler and reload
calc_timer_prescalerComputes the prescaler and the auto-reload value of a timer for an update or PWM frequency, with the real frequency, its error and the PWM duty resolution in bits. Use it to set up a periodic interrupt or a PWM output. For any timer with a 16-bit prescaler and a 16-bit or 32-bit counter that both count from 0, which is how most microcontroller timers are built.
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": {
"clock_hz": "<clock_hz>",
"frequency_hz": "<frequency_hz>"
},
"name": "calc_timer_prescaler"
}
}Input Schema
| Name | Required | Description | Default |
|---|---|---|---|
| clock_hz | Yes | The clock of the timer in Hz, which is often not the bus clock: check the clock tree of the part. | |
| counter_bits | No | The width of the counter, 16 or 32. Default 16. | |
| frequency_hz | Yes | The wanted update or PWM frequency in Hz. Fractions are allowed, such as 0.5. |