English
Language : 

PIC18F87K90 Datasheet, PDF (420/566 Pages) Microchip Technology – 64/80-Pin, High-Performance Microcontrollers with LCD Driver and nanoWatt XLP Technology
PIC18F87K90 FAMILY
27.8 Measuring Temperature Using 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
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.
EXAMPLE 27-5: ROUTINE FOR TEMPERATURE MEASUREMENT USING INTERNAL DIODE
//Initialize CTMU
CTMUICON=0x03;
CTMUCONHbits.CTMUEN=1;
CTMUCONLbits.EDG1STAT=1;
//Initialize ADC
ADCON0=0xE5;
ADCON1=0;
ADCON2=0xBE;
//ADCON and connect to Internal diode
//Right justified
ADCON0bits.GO=1;
while(ADCON0bits.GO==1);
Temp=ADRES;
;//read ADC results ( inversely proportional to temperature)
----------------------------------------------------------------------------------------------
Note: The temperature diode is not calibrated; the user will have to calibrate the diode to their application.
DS39957B-page 420
Preliminary
 2010 Microchip Technology Inc.