S32 Design Studio: Add UART to the Imported Project using AI
Introduction
In Tutorial 1, the AI agent imported the GPIO Blinking LED Demo and ran it on the FRDM-A-S32K312 board. This second article extends that project with two new features: a multi-color LED sequence, and a UART output that reports what the board is doing.
Using S32 Configuration Tools, you will map LPUART6 pins (PTA15 / PTA16), configure the peripheral at 115200 baud, regenerate code, and flash the firmware so the board echoes the current LED color over UART to a serial terminal.
Estimated time: ~20 minutes.
System Architecture
Add UART to the Imported Project – system architecture overview
The components involved are:
FRDM-A-S32K312 – Target evaluation board. Runs GPIO Blinking LED firmware with LPUART6 enabled on PTA15 (RX) / PTA16 (TX). Transmits the current LED color over UART at 115200 baud.
Host PC – Runs S32 Design Studio and the S32 Design Studio AI Support. A serial terminal (e.g. VS Code Serial Monitor) receives and displays the LED colour echo at 115200 / 8N1.
Prerequisites
What you need before starting
Tutorial 1 completed — the GPIO Blinking LED Demo for FRDM-A-S32K312 must already be imported and building in S32 Design Studio
One FRDM-A-S32K312 evaluation board + USB cable
A serial terminal application (e.g. PuTTY, Tera Term, or VS Code Serial Monitor)
S32 Design Studio AI Support configured (download, install and configure it following the steps from Installation & Usage Guide)
Note: This tutorial uses these paths:
Installation: C:\NXP\2026\K3_kit\S32DS_3.6.8
Workspace: C:\NXP\2026\K3_kit\workspace_S32DS_3.6.8_K3_kit
You can use any location. If you do, update the paths in the prompt to match.
Connect the FRDM-A-S32K312 board to the PC via USB. Open Device Manager → Ports and note the virtual COM port number – you will need it for the serial terminal.
Steps
Send the following prompts to your AI assistant in order. Each prompt is a complete, self-contained instruction.
Step 1 – Add RGB LED cycling (red → green → blue)
In S32DS, use the dm-gpio-blinky-s32k312 project on a S32K312 FRDM board.
Add pins PTA30 and PTA31 in the Pins tool (green and blue of the on-board RGB LED; red is the existing PTA29).
In the existing blink cycle where the red LED is toggled, replace it with a switch-case that lights one color at a time, cycling red -> green -> blue, ~500 ms each.
Important: these RGB LEDs are active-low. Confirm the polarity from the board schematic/user guide before writing GPIO values. Map: red=PTA29, green=PTA30, blue=PTA31.
Then generate code and build (report any errors) and flash/run it.
Use the s32ds-agentic-ai MCP server for all IDE/config/flash actions; if the MCP server disconnects at any point, stop immediately and notify me.
AI will:
Open Pins Tool and add PTA30 (green) and PTA31 (blue) alongside existing PTA29 (red)
Replace the existing blink loop with a switch-case cycling red → green → blue, ~500 ms each
Respect active-low polarity, confirmed from board schematic/user guide
Click Generate Code, build and report any errors
Flash and run the firmware on the FRDM-A-S32K312 board
Stop and notify the user immediately if the s32ds-agentic-ai server disconnects
Step 2 – Add UART functionality to echo the LED colour
Add UART functionality to echo the color of the LED (RED, GREEN, BLUE) but keep it lightweight by using the LPUART IP-layer:
- In Pins tool: map the PTA15 as LPUART6_RX and PTA16 as LPUART6_TX pins
- In Peripherals tool: set LPUART_6 channel configured for baudrate 115200 / 8 data bits / no parity / 1 stop bit
Then generate code and build (report any errors) and flash/run it.
Use the s32ds-agentic-ai MCP server; if the MCP server disconnects at any point, stop immediately and notify me.
AI will:
Open Pins Tool and map PTA15 → LPUART6_RX and PTA16 → LPUART6_TX
Open Peripherals Tool and configure LPUART6: 115200 baud / 8 data bits / no parity / 1 stop bit
Click Generate Code, build and report any errors
Flash and run the firmware on the FRDM-A-S32K312 board
Stop and notify the user immediately if the s32ds-agentic-ai server disconnects
Verifying the Result
Work through this final check to confirm that both prompts completed successfully.
Final check
Build completes with zero errors.
Firmware is flashed and running on the FRDM-A-S32K312 board (RGB LED is blinking).
Open a serial terminal at 115200 baud / 8N1 on the board's COM port.
Confirm messages such as LED: RED, LED: GREEN, LED: BLUE appear in sync with the physical LED colour changes.
Troubleshooting
Symptom
Fix
No UART output in serial terminal
Open Pins Tool. Confirm PTA15 → LPUART6_RX and PTA16 → LPUART6_TX are routed. Regenerate code after any change.
LPUART6 not found or not initialised
Open Peripherals Tool. Verify LPUART6 is enabled and configured: 115200 baud / 8 data bits / no parity / 1 stop bit. Regenerate code if you make changes.
LPUART6 absent at runtime
Open Peripherals Tool › McuPartition. Enable LPUART6 in the partition configuration, then regenerate and rebuild.
Garbled characters in serial terminal
Baud rate mismatch. Confirm the terminal is set to 115200 and the peripheral configuration matches. Regenerate code after any baud rate change.
Build errors after Generate Code
Check that the generated LPUART6_init() call is present in main.c and that the correct header is included. Re-run Generate Code if source files are missing.
LED colour not echoed over UART
Confirm the UART transmit call is placed after each LED colour change in the main loop. Verify LPUART6_init() is called before the loop starts.
Wrong COM port in serial terminal
Open Device Manager → Ports and identify the virtual COM port assigned to the FRDM-A-S32K312 board. Use that port number in your terminal application.
s32ds-agentic-ai server disconnects during operation
Stop immediately and restart the MCP server following the setup instructions. Do not continue until the server is confirmed connected.
File Reference
File
Step
Description
src/main.c
2
Main firmware file — contains LED loop and LPUART6 transmit calls
generate/src/Lpuart_Uart_Ip_PBcfg.c
1
Generated LPUART6 peripheral configuration
generate/include/Lpuart_Uart_Ip_Cfg.h
1
Generated LPUART6 configuration header
*.mex
1
S32 Configuration Tools project file (Pins, Clocks, Peripherals)
Map the pins, configure LPUART6 and regenerate – your board now reports every LED colour change over UART in about 20 minutes.
Examples
View full article