Getting Started With Renesas RA Family/FSP - Part 2 RTT Viewer
by Panos_V in Circuits > Microcontrollers
17 Views, 0 Favorites, 0 Comments
Getting Started With Renesas RA Family/FSP - Part 2 RTT Viewer
This intructable walks through using the Part 1 example project and the RTT Viewer. This tool serves as console interface, letting both displaying output messages from your application and sends input from your PC to your MCU, in real time.
Compared to the traditional/boring method of using a UART serial terminal for debugging and monitoring, RTT offers a faster and more efficient alternative, using the existing debug interface.
Although I recommend you to follow my Getting Started collection from the beginning, you can still jump right in if you’re already somewhat familiar with e2 studio and FSP
Supplies
While this tutorial works with any Renesas RA microcontroller, we'll be walking through the steps using the Evaluation Kit for RA6M4 as our example.
Download the Segger J-link RTT Viewer from this link.
Import the Project From Part 1
Follow this git link and download the project from part 1.
Next, click Import>Rename & Import Existing C/C++ Project into Workspace(cause we want to give a differnet name).
Now, we have a new identical project, ready to add some new features
Add the RTT Files
Now, you just create a new folder under the src, called SEGGER_RTT. Then, import the files attached on this step, apart from the common_utils.h which should be placed on level higher.
These files include the basic RTT functions we will use on this intructable.
Getting deep into these functions is not necessary, since we demonstrate the the very basic usage. For more details regarding the API, refer to this.
RTT Functions
Let’s take a look at what’s inside common_utils.h.
Here you’ll find:
- Macro definitions for initializing RTT
- Banner messages that we’ll display in the RTT Viewer
- Helper functions for printing messages or errors
- And a simple error trap
These utilities make it easy to send and receive text through RTT, basically giving us a “printf-style” console over the debug link!
Integrate RTT in Hal_entry.c
Now let’s make use of our new RTT utilities inside the hal_entry.c file.
Open your project’s hal_entry.c and add the following include near the top:
This allows us to use the APP_PRINT, APP_ERR_PRINT, and APP_ERR_TRAP macros defined in common_utils.h.
These macros make it super easy to send messages directly to the RTT Viewer, no need for printf() or UART setup!
Next, inside your hal_entry() function, let’s print a welcome banner when the program starts:
Let’s make our LED timer callback print something each time it runs. this will show that RTT works even during interrupts.
Update your coolTimerCallback() like this:
Now, every time the timer toggles the LED, you’ll also see “Running…” printed in the RTT Viewer in real time!
Connect RTT Viewer
Build and flash the project to your RA board (e.g., RA6M4).
Keep your debugger connected, RTT communicates through it.
Launch J-link RTT Viewer
Go to
File→ Connect or F2
and then in the RTT Viewer Configuration window, set the following options:
- Connection: USB
- J-Link Device: your connected board (e.g. R7FA6M4AF)
- Force go on connect: Enabled
- Interface: SWD
- Speed: Auto or 4000 kHz
- RTT Control Block: Search Range
Select as range 0x20000000 0x8000
This range tells RTT Viewer to look for the RTT control block in the MCU’s RAM area, where SEGGER RTT usually places it.
This tells RTT Viewer to look for the RTT control block within the first 32 kB of SRAM, which is where many compilers place the _SEGGER_RTT variable by default.
Once configured, click OK to connect. RTT Viewer will automatically open the console and start listening for messages.
Sending Input Back
RTT also allows input from the PC to the MCU, not just output.
For example, you could check if a key is pressed and read it like this:
Try adding this before the timer initialization. When you type a character in the RTT Viewer input window, your MCU will echo it back just instantly!
Build, Flash, and Watch the Magic
Now go ahead and:
- Build your project (Ctrl+B)
- Debug or run it with the RTT Viewer open
- Press a key to continue the program
- Watch the live logs appear in the console
RTT gives you a real-time, cable-free debugging console, and you can even use it alongside breakpoints and live variable watching in e² studio.