Skip to main content
Glama

Rake

Calculate timer prescaler and reload

calc_timer_prescaler
Read-onlyIdempotent

Computes 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

NameRequiredDescriptionDefault
clock_hzYesThe clock of the timer in Hz, which is often not the bus clock: check the clock tree of the part.
counter_bitsNoThe width of the counter, 16 or 32. Default 16.
frequency_hzYesThe wanted update or PWM frequency in Hz. Fractions are allowed, such as 0.5.

Schema Changelog

Changes observed during successful MCP inspections.

  1. First observed

TDQS

A3.9/5.0
Behavior4/5

Does the description disclose side effects, auth requirements, rate limits, or destructive behavior?

Annotations already declare readOnly, idempotent, non-destructive and closed-world, so safety is covered. With no output schema, the description earns credit for disclosing what the call returns: the real frequency, its error, and the PWM duty resolution in bits. It does not say what happens when the requested frequency cannot be met exactly, which is a meaningful omission for a calculator that reports an error figure.

Agents need to know what a tool does to the world before calling it. Descriptions should go beyond structured annotations to explain consequences.

Conciseness4/5

Is the description appropriately sized, front-loaded, and free of redundancy?

Two sentences, front-loaded with the computation and its outputs, followed by applicability. No filler; the second sentence is dense but each clause (prescaler width, counter width, counting from zero) constrains when the result is valid.

Shorter descriptions cost fewer tokens and are easier for agents to parse. Every sentence should earn its place.

Completeness4/5

Given the tool's complexity, does the description cover enough for an agent to succeed on first attempt?

For a three-parameter pure calculator with rich annotations and no output schema, the definition covers inputs, use case, return values and hardware applicability. It stops short of describing limits such as minimum achievable frequency or overflow behavior, but an agent has enough to call it correctly.

Complex tools with many parameters or behaviors need more documentation. Simple tools need less. This dimension scales expectations accordingly.

Parameters3/5

Does the description clarify parameter syntax, constraints, interactions, or defaults beyond what the schema provides?

Schema coverage is 100%, so all three parameters, including the fractional frequency and the clock-not-bus-clock caveat, are already documented. The description adds only marginal meaning by tying counter_bits to the '16-bit or 32-bit counter that both count from 0' hardware assumption. Baseline 3 applies when the schema carries the parameter burden.

Input schemas describe structure but not intent. Descriptions should explain non-obvious parameter relationships and valid value ranges.

Purpose4/5

Does the description clearly state what the tool does and how it differs from similar tools?

The description gives a specific verb (computes) and a specific pair of resources (prescaler and auto-reload value) plus the trigger condition (update or PWM frequency). It is unmistakable from the calc_* siblings, though it never explicitly contrasts itself with them, so a 4 rather than a 5.

Agents choose between tools based on descriptions. A clear purpose with a specific verb and resource helps agents select the right tool.

Usage Guidelines4/5

Does the description explain when to use this tool, when not to, or what alternatives exist?

"Use it to set up a periodic interrupt or a PWM output" states the situations that select this tool, and the closing sentence defines the hardware envelope (16-bit prescaler, 16- or 32-bit counter counting from 0). There is no when-not guidance or named alternative for timers outside that envelope, which keeps it below 5.

Agents often have multiple tools that could apply. Explicit usage guidance like "use X instead of Y when Z" prevents misuse.

Try in Browser

Glama MCP Gateway

Add one secure layer between your agents and this server.

Resources