AHI Functions and Explanations for Onchip Temp Sensor
Onchip Temp Sensor
In TWELITE GOLD, a temperature sensor is implemented inside the chip.
The sensor value is used as a parameter for initializing the wireless MAC layer.
Handling of Temperature Sensor During MAC Layer Initialization
- If the temperature sensor value cannot be obtained, initialization is performed with a default value of 20°C.
- If more than
G_TWENET_CHIPSENSOR_ADC_INTERVAL_MS()
milliseconds have elapsed when waking up from sleep (RAM retained), the temperature is measured again at wake-up, and the MAC layer is reinitialized based on the sensor value.
Global Variables
uint8 G_TWENET_CHIPSENSOR_AUTO_ON_BOOT()
// Macro for variable access
A configuration variable to automatically acquire the temperature sensor value. Set it in cbAppColdStart(FALSE)
.
Setting | Description | Notes |
---|---|---|
0 | Do not automatically acquire the temperature sensor value. | MAC layer temperature correction uses a fixed value (20°C). |
1 | Automatically acquire the temperature sensor value. |
uint8_t G_TWENET_CHIPSENSOR_ADC_TIMES_SCALER()
// Macro for variable access
Setting | ADC Count |
---|---|
0 | 1 |
1 | 2 |
2 | 4 |
3 | 8 |
Specifies the scaler value corresponding to the number of ADC measurements for the temperature sensor.
int32 G_TWENET_CHIPSENSOR_TEMP128TH()
// Macro for variable access
Stores the temperature measured by the chip sensor in the TWENET library (value in °C multiplied by 128).
int16 g_twenet_chipsensor_volt_on_boot;
TWENET library stores the measured voltage value [mV].
This value is recorded at the same time as the temperature sensor measurement.
uint32 G_TWENET_CHIPSENSOR_ADC_INTERVAL_MS()
= (10*60*1000ul)
// Macro for variable access
If the time elapsed since the last measurement is within the period specified by this variable, the temperature sensor reading will be skipped.
Set this in cbAppColdStart(FALSE)
.
uint8 g_twemet_chipsensor_capture_this_time;
An internal flag that determines whether to perform a temperature measurement at boot.
bAHI_AdcTemp_Measure_MW()
bool_t bAHI_AdcTemp_Measure_MW(
int32 *i32temp_128th,
int16 *i16volt_mv,
uint8 adc_times_scaler,
bool_t bTurnOnSensor)
Performs the temperature sensor measurement.
i32temp_128th
is a pointer to anint32
variable that stores the temperature measurement result.i16volt_mv
is the power supply voltage [mV] measured at the same time.adc_times_scaler
specifies the scaler value corresponding to the number of ADC measurements for the temperature sensor. For configuration values, refer to the explanation ofG_TWENET_CHIPSENSOR_ADC_TIMES_SCALER()
.- If
bTurnOnSensor
is set toTRUE
, the function powers on the temperature sensor and performs the required waiting process. If set toFALSE
, you must callvAHI_AdcTemp_TurnOn_MW()
beforehand and ensure the required wait time has passed.
vAHI_AdcTemp_TurnOn_MW()
void vAHI_AdcTemp_TurnOn_MW()
Powers on the temperature sensor. A waiting time of 100 μs is required after this call.
uint32 u32AHI_AdcTemp_GetCaptTick_MW()
uint32 u32AHI_AdcTemp_GetCaptTick_MW()
Returns the FRWT timestamp of the last temperature sensor measurement in 32KHz count units.
uint32 u32AHI_AdcTemp_GetCaptTick_msec_MW()
uint32 u32AHI_AdcTemp_GetCaptTick_msec_MW()
Returns the FRWT timestamp of the last temperature sensor measurement in milliseconds.
u32AHI_AdcTemp_ElapsedFromCapt_msec_MW(), u32AHI_AdcTemp_TickrefFromCapt_msec_MW()
uint32 u32AHI_AdcTemp_ElapsedFromCapt_msec_MW()
uint32 u32AHI_AdcTemp_TickrefFromCapt_msec_MW(uint32 tick_ref)
Returns the elapsed time in milliseconds since the last temperature measurement.