ADC temperature sensor macro definition and prototype.
Copyright (c) 2015-2018 Microchip Technology Inc. and its subsidiaries.
Macros | |
#define | ADC_12BIT_FULL_SCALE_VALUE_FLOAT 4095.0 |
#define | ADC_TEMP_SAMPLE_LENGTH 4 |
#define | INT1V_DIVIDER_1000 1000.0 |
#define | INT1V_VALUE_FLOAT 1.0 |
#define | TEMP_LOG_READ_NVM1 (*(RwReg*)NVMCTRL_TEMP_LOG) |
#define | TEMP_LOG_READ_NVM2 (*(RwReg*)NVMCTRL_TEMP_LOG + 4) |
Functions | |
float | calculate_temperature (uint16_t raw_code) |
Temperature Calculation. More... | |
void | configure_adc_temp (void) |
ADC Temperature Sensor mode configuration. More... | |
float | convert_dec_to_frac (uint8_t val) |
Decimal to Fraction Conversation. More... | |
void | load_calibration_data (void) |
Calibration Data. More... | |
#define ADC_12BIT_FULL_SCALE_VALUE_FLOAT 4095.0 |
Referenced by calculate_temperature(), and load_calibration_data().
#define ADC_TEMP_SAMPLE_LENGTH 4 |
Referenced by configure_adc_temp().
#define INT1V_DIVIDER_1000 1000.0 |
Referenced by load_calibration_data().
#define INT1V_VALUE_FLOAT 1.0 |
Referenced by calculate_temperature().
#define TEMP_LOG_READ_NVM1 (*(RwReg*)NVMCTRL_TEMP_LOG) |
#define TEMP_LOG_READ_NVM2 (*(RwReg*)NVMCTRL_TEMP_LOG + 4) |
float calculate_temperature | ( | uint16_t | raw_code | ) |
Temperature Calculation.
This function calculate fine temperature using Equation1 and Equation 1b as mentioned in data sheet section "Temperature Sensor Characteristics" of Electrical Characteristics.
References ADC_12BIT_FULL_SCALE_VALUE_FLOAT, coarse_temp, fine_temp, INT1V_VALUE_FLOAT, INT1VH, INT1VR, tempH, tempR, VADCH, and VADCR.
Referenced by adc_temp_sensor().
void configure_adc_temp | ( | void | ) |
ADC Temperature Sensor mode configuration.
This function enables internal temperature sensor feature of ADC with below Settings
GLCK for ADC -> GCLK_GENERATOR_1 (8MHz) CLK_ADC -> 512 KHz REFERENCE -> internal 1 V POSITIVE INPUT -> INTRENAL Temperature reference NEGATIVE INPUT -> SAMPLES -> 4 SAMPLE_LENGTH -> 4
References adc_enable(), adc_get_config_defaults(), adc_init(), adc_instance, ADC_TEMP_SAMPLE_LENGTH, and GCLK_GENERATOR_1.
Referenced by adc_temp_sensor().
float convert_dec_to_frac | ( | uint8_t | val | ) |
Decimal to Fraction Conversation.
This function converts the decimal value into fractional and return the fractional value for temperature calculation
Referenced by load_calibration_data().
void load_calibration_data | ( | void | ) |
Calibration Data.
This function extract the production calibration data information from Temperature log row content and store it variables for temperature calculation
References ADC_12BIT_FULL_SCALE_VALUE_FLOAT, ADCH, ADCR, convert_dec_to_frac(), INT1V_DIVIDER_1000, INT1VH, INT1VR, tempH, tempR, VADCH, and VADCR.
Referenced by adc_temp_sensor().