Neural Inverse is Open Source →
DocsPin Mux & Clock Tree

Pin Mux & Clock Tree

Pin Mux Service

Pin Allocation

Track which peripherals are using which pins:

> fw_get_pin_assignments

Returns all current pin allocations in the project.

> fw_check_pin_conflicts

Detects when two peripherals are assigned to the same physical pin.

Alternate Function Database

Each MCU has a pin-to-alternate-function mapping (e.g., PA9 can be USART1_TX at AF7, or TIM1_CH2 at AF1).

> fw_gpio_alternate_functions PA9

Lists all available alternate functions for a pin.

> fw_suggest_pin_assignment USART2_TX

Finds available pins that support the requested peripheral signal, avoiding conflicts with existing allocations.

Source Code Scanning

The pin mux service scans your source code for HAL GPIO initialization calls and automatically tracks allocations:

// Detected: PA5 allocated to SPI1_SCK (AF5)
GPIO_InitStruct.Pin = GPIO_PIN_5;
GPIO_InitStruct.Alternate = GPIO_AF5_SPI1;
HAL_GPIO_Init(GPIOA, &GPIO_InitStruct);

Pinout Visualization

> fw_pinout_show

Shows current pin assignments in a visual format.

> fw_pinout_check

Validates all pin assignments against MCU capabilities.

> fw_pinout_export format=csv

Exports pin assignments for documentation or PCB layout.

Available Pins

> fw_get_available_pins peripheral=SPI2

Lists pins that are both capable of and available for a peripheral.

Clock Tree Service

Validation

> fw_validate_clock_tree

Checks the current clock configuration against MCU constraints:

  • PLL input frequency range
  • VCO frequency range
  • Prescaler valid values
  • Maximum bus frequencies (AHB, APB1, APB2)
  • USB 48MHz requirement (if USB enabled)

Constraints

> fw_get_clock_constraints

Returns all clock constraints for the selected MCU:

  • HSE range
  • HSI frequency
  • PLL multiplier/divider ranges
  • AHB max frequency
  • APB1/APB2 max frequencies
  • Flash wait states vs frequency

PLL Solving

> fw_suggest_clock_config target=168MHz source=HSE hse=8MHz

Solves PLL parameters (M, N, P, Q) that achieve the target system clock frequency within all constraints.

Prescaler Calculation

> fw_calculate_prescaler peripheral=USART1 baudrate=115200

Calculates the correct prescaler for a peripheral given the current clock tree.

Project Clock Config Detection

The clock tree service scans your project files for existing clock configuration:

SourceWhat it reads
.ioc filesSTM32CubeMX clock settings
system_stm32*.cSystemClock_Config() function
prj.confZephyr clock DTS overlays
sdkconfigESP-IDF clock settings

Agent Tools

ToolDescription
fw_check_pin_conflictsDetect pin assignment conflicts
fw_get_pin_assignmentsList all pin allocations
fw_get_available_pinsFind free pins for a peripheral
fw_suggest_pin_assignmentSuggest optimal pin for a signal
fw_pinout_showVisualize pin assignments
fw_pinout_checkValidate all assignments
fw_pinout_exportExport pin map
fw_gpio_alternate_functionsList AFs for a pin
fw_calculate_prescalerCompute prescaler for baudrate
fw_get_clock_constraintsMCU clock limits
fw_suggest_clock_configSolve PLL for target frequency
fw_validate_clock_treeValidate current clock config

Was this page helpful?

Last edited