Mikroelektronika MikroE Development Kits MIKROE-996 数据表
产品代码
MIKROE-996
PIC18F87K22 FAMILY
DS39960D-page 400
2009-2011 Microchip Technology Inc.
27.8
Measuring Temperature
with
the
CTMU Module
The CTMU, along with an internal diode, can be used
to measure the temperature. The ADC can be con-
nected to the internal diode and the CTMU module can
to measure the temperature. The ADC can be con-
nected to the internal diode and the CTMU module can
source the current to the diode. The ADC reading will
reflect the temperature. With the increase, the ADC
readings will go low. This can be used for low-cost
temperature measurement applications.
reflect the temperature. With the increase, the ADC
readings will go low. This can be used for low-cost
temperature measurement applications.
EXAMPLE 27-5:
ROUTINE FOR TEMPERATURE MEASUREMENT USING INTERNAL DIODE
// Initialize CTMU
CTMUICON = 0x03;
CTMUCONHbits.CTMUEN = 1;
CTMUCONLbits.EDG1STAT = 1;
// Initialize ADC
ADCON0 = 0xE5;
// Enable ADC and connect to Internal diode
ADCON1 = 0x00;
ADCON2 = 0xBE;
// Right Justified
ADCON0bits.GO = 1;
// Start conversion
while(ADCON0bits.G0);
Temp = ADRES;
// Read ADC results (inversely proportional to temperature)
Note:
The temperature diode is not calibrated or standardized; the user must calibrate the diode to their application.