|
fsp_err_t | R_TSU_Open (adc_ctrl_t *p_ctrl, adc_cfg_t const *const p_cfg) |
|
fsp_err_t | R_TSU_ScanCfg (adc_ctrl_t *p_ctrl, void const *const p_extend) |
|
fsp_err_t | R_TSU_ScanStart (adc_ctrl_t *p_ctrl) |
|
fsp_err_t | R_TSU_ScanGroupStart (adc_ctrl_t *p_ctrl, adc_group_mask_t group_mask) |
|
fsp_err_t | R_TSU_ScanStop (adc_ctrl_t *p_ctrl) |
|
fsp_err_t | R_TSU_StatusGet (adc_ctrl_t *p_ctrl, adc_status_t *p_status) |
|
fsp_err_t | R_TSU_Read (adc_ctrl_t *p_ctrl, adc_channel_t const reg_id, uint16_t *const p_data) |
|
fsp_err_t | R_TSU_Read32 (adc_ctrl_t *p_ctrl, adc_channel_t const reg_id, uint32_t *const p_data) |
|
fsp_err_t | R_TSU_Close (adc_ctrl_t *p_ctrl) |
|
fsp_err_t | R_TSU_InfoGet (adc_ctrl_t *p_ctrl, adc_info_t *p_adc_info) |
|
fsp_err_t | R_TSU_Calibrate (adc_ctrl_t *const p_ctrl, void const *p_extend) |
|
fsp_err_t | R_TSU_OffsetSet (adc_ctrl_t *const p_ctrl, adc_channel_t const reg_id, int32_t offset) |
|
fsp_err_t | R_TSU_CallbackSet (adc_ctrl_t *const p_ctrl, void(*p_callback)(adc_callback_args_t *), void const *const p_context, adc_callback_args_t *const p_callback_memory) |
|
Driver for the TSU peripheral on RZ microprocessor. This module implements the ADC Interface.
Overview
Features
The TSU module supports the following features:
- Supports starting or stopping TSU module.
- Supports starting or stopping temperature sensor and A/D conversion.
- Supports reading temperature sensor data.
- Supports getting A/D conversion status.
Configuration
Build Time Configurations for r_tsu
The following build time configurations are defined in fsp_cfg/r_tsu_cfg.h:
Configuration | Options | Default | Description |
Parameter Checking |
-
Default (BSP)
-
Enabled
-
Disabled
| Default (BSP) | If selected code for parameter checking is included in the build. |
Configurations for Analog > ADC (r_tsu)
This module can be added to the Stacks tab via New Stack > Analog > ADC (r_tsu).
Configuration | Options | Default | Description |
Name | Name must be a valid C symbol | g_tsu0 | Module name. |
Clock Configuration
The TSU clock is PCLKL. The clock is configurable on the Clocks tab.
Pin Configuration
This module does not use I/O pins.
Usage Notes
Using the Temperature Sensor with the TSU
The TSU HAL module supports reading the data from the on-chip temperature sensor. The value returned from the sensor can be converted into degrees Celsius in the application program using the following formula, T = (Ds - D1) / Slope + T1, where:
- T: Measured temperature (degrees C)
- Ds: Code output by the temperature sensor at the time of temperature measurement
- T1 = 25: Temperature experimentally measured at one point (degrees C)
- D1: Code output by the temperature sensor at the time of measurement of T1
- T2 = 85: Temperature at the experimental measurement of another point (degrees C)
- D2: Code output by the temperature sensor at the time of measurement of T2
- Slope: Temperature gradient by the temperature sensor (digit/degrees C)
- Slope = (D2 - D1) / (T2 - T1) for temperature more than or equal to 25 degrees C
- Slope = (D2 - D1) / (T2 - T1) x 63 / 65 for temperature below 25 degrees C
To ensure accuracy, this 2-point calibration and also averaging the data obtained at least 8 times continuously are required.
Examples
Temperature Sensor Example
This example shows how to calculate the microprocessor temperature using the TSU.
#define TSU_EXAMPLE_SCAN_COUNT (8U)
#define TSU_EXAMPLE_CONVERSION_DELAY (20U)
#define TSU_EXAMPLE_D1 (1545)
#define TSU_EXAMPLE_SLOPE_x10000 (625)
#define TSU_EXAMPLE_10000 (10000)
#define TSU_EXAMPLE_T1 (25)
#define TSU_EXAMPLE_LOWER_LIMIT (0)
#define TSU_EXAMPLE_UPPER_LIMIT (50)
void tsu_temperature_example (void)
{
handle_error(err);
uint16_t temperature_conversion_result[TSU_EXAMPLE_SCAN_COUNT];
uint16_t ds = 0;
for (uint8_t i = 0; i < TSU_EXAMPLE_SCAN_COUNT; i++)
{
handle_error(err);
ds = (uint16_t) (ds + temperature_conversion_result[i]);
}
ds /= TSU_EXAMPLE_SCAN_COUNT;
int32_t temperature_c = ((int32_t) ds - TSU_EXAMPLE_D1) * TSU_EXAMPLE_SLOPE_x10000 / TSU_EXAMPLE_10000 +
TSU_EXAMPLE_T1;
if ((temperature_c < TSU_EXAMPLE_LOWER_LIMIT) || (temperature_c > TSU_EXAMPLE_UPPER_LIMIT))
{
__BKPT(0);
}
}
◆ tsu_instance_ctrl_t
struct tsu_instance_ctrl_t |
◆ R_TSU_Open()
Start the TSU module.
- Return values
-
FSP_SUCCESS | Module is ready for use. |
FSP_ERR_ASSERTION | An input argument is invalid. |
FSP_ERR_ALREADY_OPEN | The instance control structure has already been opened. |
◆ R_TSU_ScanCfg()
adc_api_t::scanCfg is not supported on the TSU.
- Return values
-
FSP_ERR_UNSUPPORTED | Function not supported in this implementation. |
◆ R_TSU_ScanStart()
Enable the temperature sensor and ADC. Start A/D conversion.
- Note
- Even if the A/D conversion starts, it takes time for the results to be stored. So wait until the result is stored and then read.
- Return values
-
FSP_SUCCESS | Scan started. |
FSP_ERR_ASSERTION | An input argument is invalid. |
FSP_ERR_NOT_OPEN | Unit is not open. |
FSP_ERR_IN_USE | Another scan is still in progress. |
◆ R_TSU_ScanGroupStart()
adc_api_t::scanGroupStart is not supported on the TSU.
- Return values
-
FSP_ERR_UNSUPPORTED | Function not supported in this implementation. |
◆ R_TSU_ScanStop()
Stop A/D conversion. Disable the temperature sensor and ADC.
- Return values
-
FSP_SUCCESS | Scan stopped. |
FSP_ERR_ASSERTION | An input argument is invalid. |
FSP_ERR_NOT_OPEN | Unit is not open. |
◆ R_TSU_StatusGet()
Provide the A/D conversion status.
- Return values
-
FSP_SUCCESS | Module status stored in the provided pointer p_status. |
FSP_ERR_ASSERTION | An input argument is invalid. |
FSP_ERR_NOT_OPEN | Unit is not open. |
◆ R_TSU_Read()
Reads conversion results from a sensor.
- Note
- Specify ADC_CHANNEL_TEMPERATURE for reg_id.
- Return values
-
FSP_SUCCESS | Data read into provided p_data. |
FSP_ERR_ASSERTION | An input argument is invalid. |
FSP_ERR_NOT_OPEN | Unit is not open. |
FSP_ERR_INVALID_STATE | Read command not valid in the current state. |
◆ R_TSU_Read32()
adc_api_t::read32 is not supported on the TSU.
- Return values
-
FSP_ERR_UNSUPPORTED | Function not supported in this implementation. |
◆ R_TSU_Close()
Stop the TSU module.
- Return values
-
FSP_SUCCESS | Module closed. |
FSP_ERR_ASSERTION | An input argument is invalid. |
FSP_ERR_NOT_OPEN | Unit is not open. |
◆ R_TSU_InfoGet()
adc_api_t::infoGet is not supported on the TSU.
- Return values
-
FSP_ERR_UNSUPPORTED | Function not supported in this implementation. |
◆ R_TSU_Calibrate()
adc_api_t::calibrate is not supported on the TSU.
- Return values
-
FSP_ERR_UNSUPPORTED | Function not supported in this implementation. |
◆ R_TSU_OffsetSet()
adc_api_t::offsetSet is not supported on the TSU.
- Return values
-
FSP_ERR_UNSUPPORTED | Function not supported in this implementation. |
◆ R_TSU_CallbackSet()
adc_api_t::callbackSet is not supported on the TSU.
- Return values
-
FSP_ERR_UNSUPPORTED | Function not supported in this implementation. |