Skip to main content
Glama
ethan-hub26

embedcalc-mcp

by ethan-hub26

CAN Bit Timing Calculator

embedcalc_can_bit_timing
Read-onlyIdempotent

Compute exact CAN bit timing (BRP, segments, SJW, register values) for STM32 bxCAN, FDCAN, and MCP2515 controllers from clock frequency, bitrate, and target sample point. Returns register-ready configuration closest to target sample point.

Instructions

Compute exact CAN bit timing (BRP, segments, SJW, register values) for STM32 bxCAN, STM32 FDCAN (nominal/arbitration phase), and MCP2515 from clock, bitrate, and target sample point.

Searches all valid prescaler/segment combinations and returns, per controller, the configuration whose sample point is closest to the target (ties: more TQ per bit, then smaller BRP). Register values are ready to write: bxCAN CAN_BTR, FDCAN FDCAN_NBTP, MCP2515 CNF1/CNF2/CNF3 (BTLMODE=1). All values follow the controller datasheets; BRP/TS values are 1-based (register encoding = value - 1 is already applied inside the hex words).

Args:

  • clock_hz (int): controller input clock in Hz. bxCAN: APB1; FDCAN: kernel clock; MCP2515: crystal Fosc (MCP2515 uses TQ = 2*BRP/Fosc).

  • bitrate_bps (int): nominal bitrate in bit/s (classic CAN: up to 1000000).

  • sample_point_percent (50-95, default 87.5): CiA 301 recommends 87.5.

Returns (structured): { bxcan, fdcan, mcp2515 } — each a timing object or null when the clock/bitrate ratio has no exact integer divider for that controller (a null means: change the clock or bitrate, do not approximate).

Examples:

  • "500 kbit/s on STM32F103 (APB1 36 MHz)" -> clock_hz=36000000, bitrate_bps=500000

  • "1 Mbit/s, 16 MHz MCP2515, sample point 75%" -> clock_hz=16000000, bitrate_bps=1000000, sample_point_percent=75 Do not guess CAN timing registers — call this tool.

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
clock_hzYesCAN controller input clock in Hz (bxCAN: APB1 clock; FDCAN: kernel clock; MCP2515: crystal Fosc). E.g. 36000000 for 36 MHz.
bitrate_bpsYesTarget nominal bitrate in bit/s, e.g. 500000 for 500 kbit/s.
sample_point_percentNoTarget sample point in percent. CiA 301 recommends 87.5 (the default).

Output Schema

TableJSON Schema
NameRequiredDescriptionDefault
bxcanYesSTM32 bxCAN solution, or null if no exact divider exists
fdcanYesSTM32 FDCAN nominal (arbitration phase) solution, or null
mcp2515YesMCP2515 solution (BTLMODE=1, SAM=0), or null
Behavior5/5

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

Beyond annotations (readOnly, idempotent, non-destructive), the description discloses the search algorithm, tie-breaking rules, register encoding (BRP/TS 1-based, subtraction already applied), and null handling for no exact divisor. No contradiction with annotations.

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?

Well-structured with purpose first, then algorithm, arguments, return type, examples, and warning. Slightly long (~150 words) but justified by complexity; only minor redundancy in register encoding explanation.

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

Completeness5/5

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

Comprehensive for a multi-controller timing calculator: covers algorithm, tie-breaking, register format, null returns, and example usage. Output schema exists, so return fields are not required in description. No gaps for effective use.

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

Parameters5/5

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

Schema coverage is 100% but description adds value: explains clock_hz per controller type (APB1 vs kernel vs Fosc), bitrate up to 1 Mbps for classic CAN, and sample_point_percent with CiA 301 recommendation (87.5). Examples illustrate realistic parameter values.

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

Purpose5/5

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

The description clearly states the verb 'Compute exact CAN bit timing' and specifies three target controllers (STM32 bxCAN, FDCAN, MCP2515), distinguishing it from sibling calculation tools like embedcalc_spi_timing or embedcalc_uart_baud.

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

Usage Guidelines5/5

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

Explicitly describes when to use (exact timing from clock, bitrate, sample point), what the algorithm does (searches all combinations, ties broken by TQ then BRP), and what null returns mean (change clock/bitrate). Warns 'Do not guess CAN timing registers — call this tool.'

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

Install Server

Other Tools

Latest Blog Posts

MCP directory API

We provide all the information about MCP servers via our MCP API.

curl -X GET 'https://glama.ai/api/mcp/v1/servers/ethan-hub26/embedcalc-mcp'

If you have feedback or need assistance with the MCP directory API, please join our Discord server