Build a Serial-Controlled LED Blinker on Renesas RZ Boards Using FSP (UART + GTM)
by sahana_s in Circuits > Electronics
33 Views, 0 Favorites, 0 Comments
Build a Serial-Controlled LED Blinker on Renesas RZ Boards Using FSP (UART + GTM)
In this Instructable, I'll walk you through a bare-metal application built with the Renesas Flexible Software Package (FSP) in e² studio. You'll type a number into a serial terminal, and an LED's blink speed changes instantly, a simple but powerful way to learn interrupt-driven UART handling and timer peripheral control on a real Arm Cortex-M target.
Supplies
Hardware:
- 1x RZ board (SMARC EVK) + Module Board + Carrier Board
- 1x USB Type-C cable (board power)
- 1x PMOD LED module
- 1x PMOD USBUART module
- 1x USB Type-A to micro-USB cable (serial connection to PC)
- 1x J-Link Base + J-Link 9-pin Cortex-M Adapter (debugging)
Software:
- e² studio v2026-07 or later
- RZ Flexible Software Package (FSP) v4.2.0
- GCC Arm Embedded Toolchain v13.3.1.arm-13-24 (bundled with FSP installer)
- SEGGER J-Link RTT Viewer v9.44
- Tera Term (or similar serial terminal app)
Hardware Setup - Boot Mode & Switch Configuration
Since the original table didn't copy over cleanly, here's the same configuration rewritten as a simple checklist. Set the board to Boot Mode 3 (1.8-V Single/Quad/Octal serial flash memory) using the switches below before powering on:
On the Module Board:
- SW1-1 → OFF
- SW1-2 → Don't care (leave as-is)
On the Carrier Board:
- SW1 → Don't care
- SW2 → 2-3
- SW3 → 2-3
- SW4 → Don't care
- SW5 → Don't care
- SW6 → Don't care
- SW7 → Don't care
- SW8 → Don't care
- SW11-1 → OFF
- SW11-2 → OFF
- SW11-3 → OFF
- SW11-4 → ON
- CN4 → Jumper connects 1-3 AND Jumper connects 2-4 (two separate jumper connections)
E² Studio & FSP Overview
Before wiring anything else, let's set up the software side
- e² studio is Renesas's official Eclipse-based IDE, this is where you'll write, build, flash, and debug your code
- RZ FSP (Flexible Software Package) is the HAL (Hardware Abstraction Layer) that provides ready-made drivers (like the UART and GTM drivers we're using here) so you don't have to write register-level code yourself.
- GNU Arm Toolchain is the actual compiler that turns your C code into a binary the Cortex-M core can run, this is bundled into the FSP installer automatically
Installation Steps
- Download e² studio from Renesas's official info page: "e² studio -information for RZ Family | Renesas" . This page also hosts the "Getting Started with e² studio" documentation, read that first if you've never used e² studio before.
- Download the RZ FSP package (includes e² studio plugin + toolchain) directly from the GitHub release:
- setup_rzfsp_v4_2_0_e2s_v2026-07.exe - https://github.com/renesas/rz-fsp/releases/download/v4.2.0/setup_rzfsp_v4_2_0_e2s_v2026-07.exe
- Run the installer and follow the prompts, this installs: e² studio IDE (v2026-07)
- RZ FSP v4.2.0
- GNU Arm Toolchain v13.3.1.arm-13-24 (arm-none-eabi target)
- Once installed, open e² studio and confirm the FSP version shows v4.2.0 under your project's FSP Configuration screen.
Wire It Up
- Connect CN6 on the Carrier Board to a 5V power source via USB Type-C.
- Connect the J-Link Base to the Module Board's debug connector via JTAG cable (use the J-Link 9-pin Cortex-M Adapter if needed).
- Connect PMOD0 pins 7–12 on the Carrier Board to your Pmod LED.
- Connect PMOD1 pins 1–6 on the Carrier Board to your Pmod USBUART.
- Connect J1 on the Pmod USBUART to your PC via USB Type-A to micro-USB cable.
Understand the Project Flow
Everything starts in hal_entry():
Order of operations: timer first → UART second → infinite demo loop. Each step traps on error ( APP_ERR_TRAP) instead of continuing in a broken state
How the Timer (GTM) Side Works
Opening and starting the timer:
Changing the blink speed on the fly:
The key formula: raw_count * (clock_frequency / 1000) converts "I want X ms" into "set the counter to Y ticks."
The LED toggle itself happens in a timer interrupt callback:
This fires automatically every time the timer period elapses, just flipping the LED pin. The speed is controlled entirely by set_cycle().
How the UART Side Works
Opening UART:
Capturing keystrokes — the UART callback (interrupt-driven line buffer):
Characters accumulate into g_temp_buffer one at a time; pressing Enter flips g_data_received_flag to hand off to the main loop.
The main loop, validating and applying input:
Validation pipeline: length check → digit-only check → range check (1–2000) → set_cycle().
Printing feedback back to the terminal (blocking send with timeout guard):
Build the Project in E² Studio
Open e² studio v2026-07.
Confirm FSP version 4.2.0 is selected in the project's FSP Configuration tab.
Build via Project → Build Project.
Connect the J-Link, and locate the RTT block address for your build:
- For the pre-built hex committed to the repo: 0x601105b8
- If you modified and rebuilt the project, find the new _SEGGER_RTT address in the generated .map file instead.
Flash and Run
- Click the debug button in e² studio to flash via J-Link. If a "Confirm Perspective Switch" dialog appears, click Switch.
- Program will stop at Warm_Reset_S, click the resume/run button again, then again at main(), to let the program run freely
- Open Tera Term, connect to the Pmod USBUART's COM port at 115200 bps, and enable local echo.
- Open J-Link RTT Viewer separately, the banner, instructions, and error messages print here (not Tera Term!).
- In Tera Term, type a number between 1 and 2000 and press Enter.
Expected RTT Viewer output on boot:
Expected Tera Term feedback after a valid entry:
Try 50 for a fast blink or 1500 for a slow one, the difference is very visible.
Troubleshooting
1) No RTT output at all - This is usually caused by a wrong _SEGGER_RTT block address. If you rebuilt the project yourself, recheck the generated .map file for the correct address instead of using the default one.
2) LED doesn't change speed - Double-check your PMOD0 wiring (pins 7–12 should connect to the Pmod LED). Also confirm that g_bsp_leds.p_leds[0] in your code matches the actual LED pin you configured in the FSP Configurator.
3) "Invalid input" every time - Make sure local echo is turned on in Tera Term, and that you're actually pressing Enter after typing your number — the callback only processes input when it sees a carriage return (\r) or linefeed (\n).
4) Garbage characters in terminal - Confirm Tera Term's serial port settings are correct: 115200 bps, 8 data bits, no parity, 1 stop bit (8-N-1), and no flow control.
5) e² studio won't find FSP v4.2.0 - Reinstall using the exact installer link provided earlier, then confirm under the project's FSP Configuration tab that version 4.2.0 is actually selected.
What You Learned
- How to install and configure e² studio + RZ FSP for bare-metal development
- How to structure an FSP application with timer + UART peripherals working together
- Interrupt-driven UART reception using a line-buffer pattern
- Converting user-friendly units (milliseconds) into raw hardware timer counts
- Defensive input validation before acting on serial input
- Using J-Link RTT Viewer alongside a serial terminal for debugging
Next Steps
- Add a second LED and let the user pick which one to control
- Support negative/hex input instead of digit-only validation
- Swap GTM periodic mode for PWM duty-cycle control
- Log every accepted value to RTT Viewer with a timestamp