Hello ;
I'm trying to use the built in temperature sense function of PIC16F1827 but so far I haven't had any luck with that .. All I have tried to do is reading the RAW ADC value of the silicon die operating temperature value but I don't get anything meaningful ...
I have a potentiometer connected to RB1 (analog channel 11) and the other adc reading is performed on analog channel 29 which is supposed to give me the result of the raw temperature reading of the silicon die .. When I rotate the potentiometer I see what I must see which is the actual expected raw adc reading result coming from the ADC channel 11 but the temperature reading I'm trying to get changes too while I rotate the pot and works dependent to the ADC value that I get from my potentiometer ...
I was so exciting with the idea of reading the chip temperature without any external component but It's been a total frustration ...
Code:
'****************************************************************
'* Name : PIC16F1827.BAS *
'* Author : BURAK GÜNAY *
'* Notice : Copyright (c) 2014 [select VIEW...EDITOR OPTIONS] *
'* : All Rights Reserved *
'* Date : 27.4.2014 *
'* Version : 1.0 *
'* Notes : PIC16F1827 *
'* : *
'****************************************************************
#header
errorlevel -303 ; suppress Program word too large
#ENDHEADER
#config
__CONFIG _CONFIG1, _FOSC_INTOSC & _WDTE_OFF & _PWRTE_OFF & _MCLRE_OFF & _CP_OFF & _CPD_OFF & _BOREN_OFF & _CLKOUTEN_OFF & _IESO_OFF & _FCMEN_OFF
__CONFIG _CONFIG2, _WRT_OFF & _PLLEN_ON & _STVREN_OFF & _BORV_19 & _LVP_OFF
#ENDCONFIG
'-------------------------------------------------------------------------------
'define OSC 4
'DEFINE OSC 16
define OSC 32
'OSCCON=%01101010 'OSC is @ 4 MHZ
'OSCCON=%01111000 'OSC is @ 16 MHZ
OSCCON=%11110000 'OSC is @ 32 MHZ --- PLLEN MUST BE ENABLED
'------------- LCD DEFINES ------------------------
DEFINE LCD_DREG PORTB 'LCD data port
DEFINE LCD_DBIT 4 'LCD data starting bit 0 or 4
DEFINE LCD_RSREG PORTA 'LCD register select port
DEFINE LCD_RSBIT 7 'LCD register select bit
DEFINE LCD_RWREG PORTA ' LCD read/write port
DEFINE LCD_RWBIT 5 ' LCD read/write pin bit
DEFINE LCD_EREG PORTA 'LCD enable port
DEFINE LCD_EBIT 6 'LCD enable bit
DEFINE LCD_BITS 4 'LCD bus size 4 or 8
DEFINE LCD_LINES 4 'Number lines on LCD
DEFINE ADC_BITS 10 ' ADCIN resolution (Bits)
DEFINE ADC_CLOCK 6 ' ADC clock source (Fosc/64)
DEFINE ADC_SAMPLEUS 20 ' ADC sampling time (uSec)
'------------- LCD DEFINES -------------------------
'-------------------------------------------------------------------------------
PORTA=%00000000 : PORTB=%00000000
TRISA=%00000000 : TRISB=%00000010
ANSELA=%00000 : ANSELB=%00000010
ADCON0=%00000001 : ADCON1=%11100000
FVRCON=%00110000
'-------------------------------------------------------------------------------
value var word : value=0
rawtemp var word : rawtemp=0
lcdout $fe,1
pause 500
MAIN:
adcin 11,VALUE
adcin 29,rawtemp
LCDOUT $FE,$80," ",DEC5 rawtemp," "
LCDOUT $FE,$C0," ",DEC5 VALUE," "
GOTO MAIN
Where do I make mistake ?
I'm expecting your helps , there must be at least a couple others that might have been interested in this function of such MCUs ... Thanks in advance
Bookmarks