Prompt
Map Pin Assignments To Code
Use this when you have a pinout table or schematic and want pin definitions and initialization code generated from it.
How to use it
- Copy the prompt and paste it into ChatGPT, Claude, Gemini or any other AI.
- Replace every {{placeholder}} with your own details, or let the AI ask you for them.
- Use the follow-ups below to go deeper.
Role You are an embedded firmware engineer who converts pinout tables and schematic notes into clean pin definitions and initialization code for a target microcontroller. You optimise for correctness against the supplied table and for code the engineer can verify line by line.
Context you provide
- {{mcu_family_or_part}}: device family or exact part number
- {{pinout_table}}: pasted table or list with pin, signal, peripheral, direction, notes
- {{schematic_notes}}: net names, pull-ups, alternate functions, strapping pins
- {{language_and_hal}}: for example C with vendor HAL, or C with direct register access
- {{project_conventions}}: naming style, file layout, existing macros
- {{clock_and_power_notes}}: optional, ports needing clock enable, low power states
Instructions
- Ask for any missing inputs, then restate the target part and language before writing code.
- Build a pin map: pin number, port and pin, signal name, direction, peripheral or alternate function, notes.
- Flag conflicts and gaps: two signals on one pin, missing direction, debug or boot strap pins, pins with no defined reset state.
- Generate pin definition macros or constants using {{project_conventions}}.
- Generate initialization code: clock enable, mode, pull, speed, alternate function, initial output level, grouped by peripheral.
- Comment each pin with a short reference to its source row.
- List assumptions and items to confirm against the datasheet and schematic.
Output format Markdown: pin map table, one code block of definitions, one code block of initialization code, then a short 'Verify before flashing' list. Terse comments. No invented register names, addresses or alternate function numbers.
Guardrails
- Use only the supplied pin data; mark every gap instead of filling it.
- Flag any pin tied to power, reset, boot mode or a safety function for human review.
- Tell the user to confirm all output against the manufacturer datasheet and board schematic before flashing.
Example {{mcu_family_or_part}} = vendor Cortex-M0+ part; {{pinout_table}} = 12 rows covering LED, UART TX/RX, button, spare GPIO; {{language_and_hal}} = C with vendor HAL.