Microchip® Advanced Software Framework

adc_temp.c File Reference

ADC Temperature Sensor configuration file.

Copyright (c) 2015-2018 Microchip Technology Inc. and its subsidiaries.

#include <asf.h>
#include "adc_temp.h"

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...
 

Variables

struct adc_module adc_instance
 Support and FAQ: visit Microchip Support More...
 
uint16_t ADCH
 
uint16_t ADCR
 
float coarse_temp
 
float fine_temp
 
float INT1VH
 
float INT1VR
 
float tempH
 
float tempR
 
float VADCH
 
float VADCR
 

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().

uint16_t ADCH

Referenced by load_calibration_data().

uint16_t ADCR

Referenced by load_calibration_data().

float coarse_temp

Referenced by calculate_temperature().

float fine_temp

Referenced by calculate_temperature().

float INT1VH
float INT1VR
float tempH
float tempR
float VADCH
float VADCR