All About Circuits

Industry White Paper

Measuring On-Chip Heat: Reading the Internal Temperature Sensor on the EK-RA8D1

Learn how to read the internal temperature sensor on the Renesas EK-RA8D1 using the ADC, factory calibration data, and e² studio to monitor die temperature without external parts.


October 15, 2026 by Renesas Electronics

You are designing a high-performance industrial controller, and managing thermal load is the only thing standing between stable operation and a silent hardware failure. Adding an external thermistor requires extra board real estate, additional component costs, and complex routing across your printed circuit board. The most elegant solution is already sitting right inside your silicon. Modern microcontrollers feature built-in temperature sensors read by the analog-to-digital converter (ADC), allowing the chip to monitor its own thermal environment directly.

This article shows you how to configure the internal ADC temperature sensor on the Renesas EK-RA8D1 Evaluation Kit. Using the e² studio IDE and the Flexible Software Package (FSP), you will configure the standard ADC stack and increase your project heap memory to support complex string formatting. You will write a C application to pull raw ADC data, apply the onboard 125°C factory calibration values, and compute a precise temperature reading. By mastering this technique, you can implement dynamic thermal throttling and compensate for temperature drift in precision measurement applications.

 

Project Specs

Target Board EK-RA8D1 Evaluation Kit
MCU Family Renesas RA8 Series
Peripheral Covered Analog-to-Digital Converter (r_adc) and Temperature Sensor
IDE/Toolchain e² studio + FSP
Interface Used SEGGER J-Link RTT Viewer
Baud Rate N/A
Skill Level Intermediate
Build Time 25 minutes
Prerequisites e² studio installed, board initialized, RTT Viewer configured

 

Why Measuring Internal Temperature Matters

Without a strategy to monitor heat, an embedded processor running intensive calculations at maximum clock speeds will eventually overheat, because silicon behaves unpredictably at thermal extremes. So, actively reading the internal temperature sensor gives your software the context it needs to make intelligent decisions based on environmental stress.

The internal temperature sensor provides an analog voltage that varies with the temperature of the die. By routing this internal signal to the onboard ADC and applying a mathematical formula derived from specific factory calibration values, you can extract an accurate temperature reading in standard °C. This capability is frequently utilized in high-power industrial motor drives, sealed internet of things enclosures exposed to direct sunlight, and precision measurement tools where thermal drift severely affects analog accuracy.

Furthermore, monitoring internal thermals enables you to write routines that throttle processor speeds or disable non-essential peripherals before critical damage occurs. Utilizing the built-in sensor saves you the trouble of managing external components over I2C or SPI buses. The RA8D1 MCU gives you direct access to this thermal data, ensuring your final product can protect itself regardless of the deployment environment.

 

What You'll Need

Hardware

 

Software

 

The Concept in 60 Seconds

The internal temperature sensor outputs a specific analog voltage that shifts predictably as the silicon gets hotter. To make physical sense of this shifting voltage, the microcontroller stores a highly specific calibration value in its hardware memory during manufacturing. This value represents the exact ADC reading generated when the chip was subjected to 125°C at the factory.

By executing a fresh ADC reading in your application, converting both it and the factory calibration value into voltages, and subtracting that voltage difference from the 125°C baseline divided by a known physical slope coefficient, you calculate the exact current temperature of the board. The fundamental complexity in this project does not come from capturing the reading itself. The true challenge lies in executing the floating-point mathematics correctly to prevent integer truncation and ensuring your memory heap is large enough to format the resulting float data into readable text for the debug terminal.

 

Step-by-Step: Building the Project

Step 1: Create a New Project for the EK-RA8D1

  1. Open your e² studio IDE and create a new Renesas C/C++ project.
  2. Name the project EK_RA8D1_Temp_sensor and target the EK-RA8D1 board using FSP version 6.3.0. Also select Executable and the No RTOS option.

 

Figure 1. Creating the EK-RA8D1 project in e² studio. Image used courtesy of Renesas

 

  1. Select a Flat (Non-TrustZone) project structure and choose the Bare Metal - Minimal template.

Starting with a minimal template removes unnecessary driver overhead so you can focus entirely on the analog sensor.

 

Step 2: Add the ADC Peripheral Stack

  1. Open the FSP Configuration perspective and navigate to the Stacks tab. Click on New Stack, hover over the Analog category, and select the ADC (r_adc) stack.

Adding this stack imports all the underlying hardware abstraction layer code required to drive the analog-to-digital converter.

  1. Click on the newly added stack block to reveal its configuration properties.

 

Step 3: Enable the Internal Temperature Sensor Channel

  1. In the Properties window for the ADC stack, expand the Input settings tab. Under the Channel Scan Mask section, scroll down and check the box for Temperature Sensor.

 

Figure 2. Enabling the temperature sensor channel in the ADC stack properties. Image used courtesy of Renesas

 

  1. Expand the Addition/Averaging Mask Channel section and check the Temperature Sensor box there as well.

These selections tell the multiplexer to route the internal thermal diode signal directly into the ADC sampling circuit.

 

Step 4: Configure the Scan Complete Interrupt

  1. Expand the Interrupt tab in the same Properties window. Type g_adc_callback into the callback field.
  2. Select a Scan End Interrupt Priority of Priority 5.

Assigning an interrupt priority is absolutely critical. Without it, the hardware has no way to notify your application that the analog voltage has successfully finished converting into a digital value.

 

Step 5: Expand the Project Heap Memory

  1. Navigate to the BSP tab in your FSP configuration and scroll down to the RA Common properties. Locate the Heap size variable and change the value from default to 0x2000. This expands the heap memory to 8 kilobytes, providing sufficient space for the dynamic memory allocation that floating-point string formatting requires (minimum 4,000 bytes).

 

Figure 3. Setting the heap size to 0x2000 in the BSP RA Common properties. Image used courtesy of Renesas

 

You must allocate this extra memory because you will be utilizing the standard C library function sprintf to parse complex floating-point numbers. Standard formatting functions require dynamic memory allocation to process variable length strings safely.

  1. Once changed, click the Generate Project Content button. Once the project is generated, you should see the r_adc stack available under Developer Assistance.

 

Step 6: Import the RTT Logging Utilities

  1. Expand the src folder and open the hal_entry.c file. Add the SEGGER RTT source code to your project, then include the common_utils.h file.
  2. Build the project to check whether everything is configured correctly, then use the APP_PRINT function to print the banner information defined in the utility file.

The SEGGER Real-Time Transfer provides a high-speed debug interface to stream text without needing a dedicated UART peripheral, and printing the banner verifies this communication link is fully operational before capturing sensor data.

 

Step 7: Define the Global Variables

  1. Define a slope variable according to the hardware manual. Specify a slope of 4.0 mV per degree Celsius, so define a constant float as 4.0f / 1000.0f. Next, define a variable to store the ADC value, a float variable to store the final temperature value, a 32-bit integer for the calibration value, and variables for the v1 calculation.
  2. Define a data array to store the information printed on the terminal, and define a volatile flag variable to indicate when an interrupt is received.

Establishing these variables upfront ensures that the system correctly handles the floating-point arithmetic required to convert raw analog data into accurate Celsius readings.

 

Step 8: Implement the Callback Function

  1. From the Developer Assistance tab, drag and drop the ADC callback function into the hal_entry.c file.
  2. Inside the function, set the flag variable to true, define an ADC event variable to identify the trigger, and use the p_args parameter to store the event information.

 

Figure 4. The ADC callback function sets the flag and stores the event information. Image used courtesy of Renesas

 

This interrupt-driven approach allows the CPU to focus on other tasks or enter into low-power states, rather than constantly polling the ADC hardware to see if a conversion is finished.

 

Step 9: Initialize the ADC Peripheral

  1. In the hal_entry function, define an fsp_err_t variable to check the status of function calls. From the Developer Assistance tab, drag and drop the ADC open function call into the hal_entry.c file, then use the assert function to check if it was successful.
  2. From Developer Assistance, drag and drop the ADC scan config function and assert its success.

Initializing the peripheral primes the internal registers and locks in the configurations you already defined in the graphical interface.

 

Step 10: Trigger the Scan and Read Data

  1. Define a while(1) loop and start by adding the ADC scan start function call, followed by an assert function. Next, use a while(1) loop to wait until the interrupt flag variable is set.
  2. Once set, use an assert statement to verify the scan complete event matches ADC_EVENT_SCAN_COMPLETE.
  3. Drag and drop the ADC read function call from Developer Assistance, using ADC_CHANNEL_TEMPERATURE as the second argument, and assert its success. For the last argument, use g_adc_val, and also assert to ensure the ADC read function call was successful.

Using a blocking loop linked to the interrupt flag ensures that the processor only reads the data register when a fresh, fully converted temperature reading is absolutely guaranteed to be ready.

 

Step 11: Calculate the Temperature

  1. Read the Temperature Sensor Calibration Data Register (TSCDR) value, and using the hardware manual formula, calculate v1 and vs to determine the internal temperature of the RA8D1.
  2. Serialize the print buffer in the data array using sprintf, and log the data on the RTT terminal using the APP_PRINT function.
  3. Add a 2-second software delay using R_BSP_SoftwareDelay, and reset the interrupt flag variable at the end.

 

Figure 5. Calculating the die temperature from the TSCDR value and the ADC reading. Image used courtesy of Renesas

 

Applying the hardware-specific slope to the voltage difference translates the raw electrical state into a human-readable format, while the software delay prevents the terminal from being overwhelmed with redundant data.

 

Step 12: Build the Code and Verify Output

  1. Click the hammer icon to compile your code. Open the .map file in a text editor, search for .bss._SEGGER_RTT, and copy the address.
  2. Right-click your project name, select Debug As, and select Renesas GDB Hardware Debugging. Click the switch button to open the debug perspective, then click the resume button. After every two seconds, the internal temperature of the RA8D1 will display.
  3. Open the SEGGER J-Link RTT Viewer, select your target device, use the address option to paste the address, and connect to the terminal.

The RTT Viewer operates by directly reading the microcontroller's background memory, which means it relies on the exact address found in your compiled map file to successfully intercept the print statements over the SWD interface.

 

Code Snippet

// Convert factory calibration integer and current ADC integer to physical voltages
v1 = 3.3f * ((float)cal_125 / 4095.0f);
vs = 3.3f * ((float)g_adc_val / 4095.0f);
 
// Calculate final die temperature using hardware slope and 125C baseline
g_degC_temp = 125.0f - ((vs - v1) / SLOPE);
 
// Format output string and print to SEGGER RTT terminal
sprintf(data, "MCU measured Temperature is %f \r\n", g_degC_temp);
APP_PRINT("%s", data);

 

What You Should See

After pasting your memory address and connecting the RTT Viewer, the terminal begins displaying a continuous stream of temperature values arriving every two seconds. The initial measurements display the ambient room temperature of the physical microcontroller die. If you place a warm object near the processor, you will immediately see printed values begin to rise.

 

Figure 6. RTT Viewer output showing the measured MCU temperature every two seconds. Image used courtesy of Renesas

 

Troubleshooting

The Program Crashes Entirely When Attempting to Print the Temperature Output

Using standard C string formatting with floating-point variables requires a substantial amount of dynamic memory. Double-check that your heap size under the BSP RA Common tab is explicitly set to 0x2000 bytes. If it remains at the default size, the processor will hit a hard fault.

 

The Calculated Temperature Reads Zero or Is Wildly Incorrect

Verify your variable casting types. The calculation requires converting the raw 12-bit ADC values into explicit floats before performing the voltage division. Ensure you are dividing by 4095.0f to force floating-point mathematics and prevent the compiler from truncating the results down to zero.

 

The Application Hangs Indefinitely on the While Loop Waiting for the Interrupt

Confirm that you assigned a valid scan end interrupt priority inside the ADC stack properties. Additionally, make sure the callback function name you typed into the FSP graphical tool perfectly matches the function signature you defined inside your C file.

 

Where to Take It Next

Now that you can consistently read the internal thermal sensor, try altering your execution logic to trigger a GPIO pin if the temperature exceeds a predefined safety threshold (for example, 45°C). You can generate localized heat manually by running intensive computational loops on the processor to test your safety trigger.

 

Frequently Asked Questions

Why Do I Need to Increase the Project Heap Size Just to Print a Number?

Standard C library functions that parse and format strings containing floating-point numbers require dynamic memory allocation to process the variable text lengths safely. The default minimal heap provided by the bare metal template is simply too small to handle this allocation.

 

What Does the Number 125 Represent in the Final Mathematical Calculation?

The number 125 refers to 125°C. Renesas calibrates this specific microcontroller family at the factory by recording the exact ADC output when the die is subjected to 125°C. This specific integer is stored permanently in the TSCDR register for you to reference.

 

Can I Utilize the ADC Peripheral for Other External Sensors at the Same Time?

Yes. You can configure the exact same ADC module to scan multiple external analog pins in a structured sequence alongside the internal temperature sensor. The single scan complete interrupt will fire once all the enabled analog channels have been successfully converted into digital values.

 

Related Resources