MPASM 02.80 Released GLASS.ASM 11-3-2002 21:23:57 PAGE 1 LOC OBJECT CODE LINE SOURCE TEXT VALUE 00001 ; LIST P = 16C74, F = INHX8M 00002 TITLE "Thermometer, RTD rev 1.0" 00003 ;********************************************************* 00004 ; PROJECT: THCHK REV. 1.0 00005 ; By: Ray Gallant DATE: 11-03-02 00006 ; email: rayg@nb.sympatico.ca 00007 ; instant messenger active 00008 ; I would like your feedback; positive, negative, foolish, errors, 00009 ; typos, concepts, or any other form. Lay it on the line please! 00010 ; PROBE = 00011 ; PROCESSOR SETUP AS 16C74 00012 ; CLOCK: 4MHz 00013 ; PROGRAM CLOCK TYPE = XT 00014 ; PROGRAM CODE PROTECTED 00015 ; POWER ON TIMER ACTIVE 00016 ; CHECK SUM ON MASTER = 00017 ; FILE NAME = C:\PROGRAM FLIES\MPLAB\glass.HEX 00018 ; PROJECT FILE = C:\PROGRAM FILES\MPLAB\glass.PJT 00019 ; MPLAB VER 5.4 00020 ;********************************************************* 00021 ;SOFTWARE DETAILS 00022 ;********************************************************* 00023 ;THERE IS NO SPELL CHECK IN THIS PFE EDITOR! SO PARDON THE TYPOS! 00024 ;READ RTD BETWEEN SERVICING THE DISPLAY. AFTER 16 SAMPLES, 00025 ;UPDATE THE RESULT. TO MANAGE ANY FLICKERING OF LAST DECIMAL 00026 ;POINTED DIGIT. ONLY UPDATE THIS LAST DIGIT DATA TWICE PER SECOND. 00027 ;IN SLEEP MODE THE UNIT WILL RETAIN THE USER'S CHOSEN OPTION OF 00028 ;Deg C OR F WHICH IS DONE VIA THE C/F MOMEMTARY SWITCH DEPRESSION. 00029 ;THE ON/OFF MOMEMTARY SWITCH: THIS SWITCH IS TOGGLED TO POWER UP 00030 ;THE UNIT OR TO PUT IT IN SLEEP MODE. ANOTHER REASON FOR THE SLEEP 00031 ;MODE, IS THE DATA RETENTION OF THE REGISTER "DEGCF" OF THE USER'S 00032 ;LAST Deg C OR F FEATURE SELECTION. 00033 ;AN AWAKE FROM SLEEP MODE DOES NOT ERRASE THAT VALUE AND THUS I 00034 ;AM NOT REQUIRING AN EXTERNAL SINGLE WORD DATA STORAGE. SCHEME FOR 00035 ;Deg C TO Deg F CONVERSION WITHOUT USING DIVIDE ROUTINE IS COMPLETE. 00036 ;ALPHA-NUMERICS THAT I CAN PRINT ARE: 0 1 2 3 4 5 6 7 8 9 00037 ; A b c d g h C E F H L P S t 00038 ;WORDS INCLUDE: 0FF bAt 0Ut tESt CAL L0 H1 b10 1F PUt 00039 ;********************************************************* 00040 ;SCOPE CHa & CHb TEST POINTS = LCD PIN 1 & PIN 3 00041 ;********************************************************* 00042 ;/////////////////////////////////////////////////////////// 00043 ;\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\ 00044 ;********************************************************* 00045 ;PORTS CONFIGURATIONS 00046 ;********************************************************* 00047 ;PORT A - RTD, SHUT DOWN LP2951, DEGREE C/F SWITCH 00048 ; 5 4 3 2 1 0 00049 ; | | | | | +---- I - 7893 PIN 5, DATA, PIC PIN 2 00050 ; | | | | +------ O - 7893 PIN 7, CONVERT, PIC PIN 3 00051 ; | | | +-------- O - OUTPUT SHUT DOWN LP2951ACN 00052 ; | | +---------- I - VREF PIC A/D, NOT USED, FREE 00053 ; | +------------ I - Deg C / Deg F MOMENTARY SWITCH, TOGGLES MPASM 02.80 Released GLASS.ASM 11-3-2002 21:23:57 PAGE 2 Thermometer, RTD rev 1.0 LOC OBJECT CODE LINE SOURCE TEXT VALUE 00054 ; +-------------- O - 7893 PIN 4, CLK 00055 ;********************************************************* 00056 ;PORT B - INT - ON/OFF (SLEEP) SWITCH, LCD PLANE VOLTAGES, 00057 ; 7 6 5 4 3 2 1 0 DATA OUT JUMPER, DATA OUT 00058 ; | | | | | | | +---- I - ON/OFF (SLEEP) MOMENTARY SWITCH 00059 ; | | | | | | +------ I - FREE 00060 ; | | | | | +-------- I - SET = DATA OUT ENABLE JUMPER 00061 ; | | | | +---------- O - SINGLE PIN PROTOCOL, DATA OUT 00062 ; | | | +------------ O - COM1A - 1K RESISTOR TO LCD-PIN-17 00063 ; | | +-------------- O - COM1B - 1K RESISTOR TO LCD-PIN-17 00064 ; | +---------------- O - COM2A - 1K RESISTOR TO LCD-PIN-1 00065 ; +------------------ O - COM2B - 1K RESISTOR TO LCD-PIN-1 00066 ;********************************************************* 00067 ;PORT C - LCD DATA, COLON, 4TH NUMERIC, DEG C/F ICONS, ASYNC 00068 ; 7 6 5 4 3 2 1 0 00069 ; | | | | | | | +---- O - 15 COM1-3d, COM2-minus LCD-PIN-7 00070 ; | | | | | | +------ O - 16 COM1-3c, COM2-3b LCD-PIN-14 00071 ; | | | | | +-------- O - 17 COM1-3g, COM2-3a LCD-PIN-13 00072 ; | | | | +---------- O - 18 COM1-3e, COM2-3f LCD-PIN-12 00073 ; | | | +------------ O - 23 COM1-n/c,COM2-Y LCD-PIN-15 00074 ; | | +-------------- O - 24 COM1-Z2, COM2-Z1 LCD-PIN-16 00075 ; | +---------------- I - RX FREE 00076 ; +------------------ O - TX FREE 00077 ;********************************************************* 00078 ;PORT D - LCD DATA, K, 2ND NUMERIC, 3RD NUMERIC, DP 00079 ; 7 6 5 4 3 2 1 0 00080 ; | | | | | | | +---- O - 19 COM1-2d, COM2-DP LCD-PIN-11 00081 ; | | | | | | +------ O - 20 COM1-2c, COM2-2b LCD-PIN-10 00082 ; | | | | | +-------- O - 21 COM1-2g, COM2-2a LCD-PIN-9 00083 ; | | | | +---------- O - 22 COM1-2e, COM2-2f LCD-PIN-8 00084 ; | | | +------------ O - 27 COM1-1d, COM2-K LCD-PIN-3 00085 ; | | +-------------- O - 28 COM1-1c, COM2-1b LCD-PIN-6 00086 ; | +---------------- O - 29 COM1-1g, COM2-1a LCD-PIN-5 00087 ; +------------------ O - 30 COM1-1e, COM2-1F LCD-PIN-4 00088 ;********************************************************* 00089 ;PORT E - BATTERY MONITOR 00090 ; 2 1 0 00091 ; | | +-- I - FREE 00092 ; | +---- I - FREE 00093 ; +------ I - LP2951ACN BATTERY LOW FEEDBACK 00094 ;********************************************************* 00095 ;DEGCF REGISTER 00096 ; 7 6 5 4 3 2 1 0 00097 ; | | | | | | | +-- COUNTER BO FOR DIGIT BEING SERVICED 00098 ; | | | | | | +----- COUNTER B1 FOR DIGIT BEING SERVICED 00099 ; | | | | | +-------- SET = DISPLAYING COLON (on old glass only) 00100 ; | | | | +----------- SET = DISPLAYING DP (DECIMAL POINT) 00101 ; | | | +-------------- SET = IN SLEEP MODE 00102 ; | | +----------------- SET = WAS IN BANK1 WHEN INTERRUPTED 00103 ; | +-------------------- CLR = DISPLAYING MINUS SIGN 00104 ; +----------------------- SET = DISPLAYING DEG F 00105 ;********************************************************* 00106 ;DSPLAY REGISTER MPASM 02.80 Released GLASS.ASM 11-3-2002 21:23:57 PAGE 3 Thermometer, RTD rev 1.0 LOC OBJECT CODE LINE SOURCE TEXT VALUE 00107 ; 7 6 5 4 3 2 1 0 00108 ; | | | | | | | +-- SET = 00109 ; | | | | | | +----- SET = 00110 ; | | | | | +-------- SET = 00111 ; | | | | +----------- SET = SINGLE PIN XMIT PROTOCOL DATA OUT 00112 ; | | | +-------------- SET = INDICATES A NEW VALUE IS AVAILABLE 00113 ; | | +----------------- SET = DISPLAY Y 00114 ; | +-------------------- SET = ALL DIGIT COMPLETLY DISPLAYED 00115 ; +----------------------- SET = 12 BIT A/D 1ST 8 BITS IN 00116 ;********************************************************* 00117 ;LEADG0 REGISTER MANAGING NOT TO PRINT LEADING ZEROES 00118 ; 7 6 5 4 3 2 1 0 00119 ; | | | | | | | +---- - K IS ZERO 00120 ; | | | | | | +------ - 1ST DIGIT IS ALSO ZERO 00121 ; | | | | | +-------- - 2ND DIGIT IS ALSO ZERO 00122 ; | | | | +---------- - 00123 ; | | | +------------ - 00124 ; | | +-------------- - 00125 ; | +---------------- - 00126 ; +------------------ - 00127 ;********************************************************* 00128 ;NMFLAG REGISTER 00129 ; 7 6 5 4 3 2 1 0 00130 ; | | | | | | | +---- - CLR = (ACCaHI,ACCaLO = ACCbHI,ACCbHI) 00131 ; | | | | | | +------ - CLR = (ACCaHI, ACCaLO = 0) 00132 ; | | | | | +-------- - CLR = (ACCbHI, ACCaLO = 0) 00133 ; | | | | +---------- - CLR = (ACCaHI, ACCaLO > ACCbHI, ACCbLO) 00134 ; | | | +------------ - CLR = (ACCbHI, ACCbLO > ACCaHI, ACCaLO) 00135 ; | | +-------------- - 00136 ; | +---------------- - 00137 ; +------------------ - 00138 ;********************************************************* 00139 ; THE FOLLOWING PRACTICE IS NOT REQUIRED, BUT HELPFUL FOR TROUBLESHOOTING! 00140 ; IT IS IMPORTANT TO HAVE 2 DUPLICATE REGISTERS TO SUPPORT 00141 ; THE STORAGE OF PCLATH, STATUS AND WREG, FOR WE WANT TO VERIFY 00142 ; WHICH RESISTER BANK WE WILL BE IN WHEN WE GET INTERRUPTED. 00143 ; CBLOCK REGISTER ASSIGNMENTS HAS BEEN ADJUSTED SO, TO RECONFIRM. 00144 ; THE DATA BOOK MENTIONS THAT PCLATH IS STACKED DURING THE INTERRUPT, 00145 ; I AGREE, BUT I STORE IT ANYWAY FOR TROUBLESHOTING PURPOSES. 00146 ; DUPLICATE REGISTER IN THE HIGH BANK ARE ISTATH,IWREGH 00147 ; WHICH MATCH THE ADDRESS IN THE LOWER BANK (ISTAT,IWREG) 00148 ;********************************************************* 00149 ; DEFINITION TABLE 00150 ;********************************************************* 00151 CBLOCK 0x00 ;BANK0 REGISTERS 00000000 00152 INDF,TMR0,PCL,STATUS,FSR,PORTA,PORTB 00000007 00153 PORTC,PORTD,PORTE,PCLATH,INTCON,PIR1 0000000D 00154 PIR2,TMR1L,TMR1H 00155 ENDC 00156 CBLOCK 0x10 ;BANK0 REGISTERS 00000010 00157 T1CON,TMR2,T2CON,SSPBUF,SSPCON,CCPR1L 00000016 00158 CCPR1H,CCP1CON,RCSTA,TXREG,RCREG,CCPR2L 0000001C 00159 CCPR2H,CCP2CON,ADRES,ADCON0 MPASM 02.80 Released GLASS.ASM 11-3-2002 21:23:57 PAGE 4 Thermometer, RTD rev 1.0 LOC OBJECT CODE LINE SOURCE TEXT VALUE 00160 ENDC 00161 CBLOCK 0x20 ;A/D, SINGLE PIN COMM, LCD, BATTERY 00000020 00162 HIBYTE,LOBYTE,PARITY,NETID 00000024 00163 DIGTHI,DIGTLO,FREE26,FREE27 00000028 00164 FREE28,FREE29,TEMP1,BATCNT 0000002C 00165 DCML0,DCML1,DCML2,DCMTMP 00166 00167 ENDC 00168 CBLOCK 0x30 ;LCD BUFFERS & 5 DIGIT BCD REGs 00000030 00169 LCDTMP,DEGCF,DSPLAY,LEADG0 00000034 00170 HCOM1A,LCOM1A,HCOM2A,LCOM2A 00000038 00171 DIGITS,WREG0,DCIML0,DCIML1 0000003C 00172 DCIML2,HBYTE,LBYTE,BCDTMP 00173 ENDC 00174 CBLOCK 0x40 ;REGs 00000040 00175 FREE40,FREE41,FREE42,FREE43 00000044 00176 FREE44,FREE45,FREE46,FREE47 00000048 00177 FREE48,FREE49,FREE4A,FREE4B 0000004C 00178 FREE4C,FREE4D,FREE4E,FREE4F 00179 ENDC 00180 CBLOCK 0x50 ;PUSH/POP,TMP,TMR1 COUNT 00000050 00181 FREE50,FREE51,FREE52,FREE53 00000054 00182 FREE54,FREE55,FREE56,FREE57 00000058 00183 FREE58,FREE59,FREE5A,FREE5B 0000005C 00184 SLOW,IPCLAT,ISTAT,IWREG 00185 ENDC 00186 CBLOCK 0x60 ;REG's 00000060 00187 FREE60,FREE61,FREE62,FREE63 00000064 00188 FREE64,FREE65,FREE66,FREE67 00000068 00189 FREE68,FREE69,FREE6A,FREE6B 0000006C 00190 FREE6C,FREE6D,FREE6E,FREE6F 00191 ENDC 00192 CBLOCK 0x70 ;REGs 00000070 00193 FREE70,FREE71,FREE72,FREE73 00000074 00194 FREE74,FREE75,FREE76,FREE77 00000078 00195 FREE78,FREE79,FREE7A,FREE7B 0000007C 00196 FREE7C,FREE7D,FREE7E,FREE7F 00197 ENDC 00198 ; 00199 ;BANK1 REGISTERS BANK1 REGISTERS BANK1 REGISTERS BANK1 REGISTERS 00200 CBLOCK 0x81 ;BANK1 REGISTERS 00000081 00201 OPTN 00202 ;DON'T USE "OPTION", USE OPTN INSTEAD 00203 ENDC 00204 CBLOCK 0x85 ;BANK1 REGISTERS 00000085 00205 TRISA,TRISB,TRISC,TRISD,TRISE 00206 ENDC 00207 CBLOCK 0x8C ;BANK1 REGISTERS 0000008C 00208 PIE1,PIE2,PCON 00209 ENDC 00210 CBLOCK 0x92 ;BANK1 REGISTERS 00000092 00211 PR2,SSPADD,SSPSTAT 00212 ENDC MPASM 02.80 Released GLASS.ASM 11-3-2002 21:23:57 PAGE 5 Thermometer, RTD rev 1.0 LOC OBJECT CODE LINE SOURCE TEXT VALUE 00213 CBLOCK 0x98 ;BANK1 REGISTERS 00000098 00214 TXSTA,SPBRG 00215 ENDC 00216 CBLOCK 0x9F ;ASYNC STORAGE AND FLAGS 0000009F 00217 ADCON1 00218 ENDC 00219 CBLOCK 0xA0 ;REGs 000000A0 00220 FREEA0,FREEA1,FREEA2,FREEA3 000000A4 00221 FREEA4,FREEA5,FREEA6,FREEA7 000000A8 00222 FREEA8,FREEA9,FREEAA,FREEAB 000000AC 00223 FREEAC,FREEAD,FREEAE,FREEAF 00224 ENDC 00225 CBLOCK 0xB0 ;REGs 000000B0 00226 FREEB0,FREEB1,FREEB2,FREEB3 000000B4 00227 FREEB4,FREEB5,FREEB6,FREEB7 000000B8 00228 FREEB8,FREEB9,FREEBA,FREEBB 000000BC 00229 FREEBC,FREEBD,FREEBE,FREEBF 00230 ENDC 00231 CBLOCK 0xC0 ;REGs 000000C0 00232 FREEC0,FREEC1,FREEC2,FREEC3 000000C4 00233 FREEC4,FREEC5,FREEC6,FREEC7 000000C8 00234 FREEC8,FREEC9,FREECA,FREECB 000000CC 00235 FREECC,FREECD,FREECE,FREECF 00236 ENDC 00237 CBLOCK 0xD0 ;INTERRUPT TEST REGs, HIGH BANK 000000D0 00238 FREED0,FREED1,FREED2,FREED3 000000D4 00239 FREED4,FREED5,FREED6,FREED7 000000D8 00240 FREED8,FREED9,FREEDA,FREEDB 000000DC 00241 FREEDC,FREEDD,ISTATH,IWREGH 00242 ENDC 00243 CBLOCK 0xE0 ;REGs 000000E0 00244 FREEE0,FREEE1,FREEE2,FREEE3 000000E4 00245 FREEE4,FREEE5,FREEE6,FREEE7 000000E8 00246 FREEE8,FREEE9,FREEEA,FREEEB 000000EC 00247 FREEEC,FREEED,FREEEE,FREEEF 00248 ENDC 00249 CBLOCK 0xF0 ;REGs 000000F0 00250 FREEF0,FREEF1,FREEF2,FREEF3 000000F4 00251 FREEF4,FREEF5,FREEF6,FREEF7 000000F8 00252 FREEF8,FREEF9,FREEFA,FREEFB 000000FC 00253 FREEFC,FREEFD,FREEFE,FREEFF 00254 ENDC 00255 ;********************************************************* 00256 ; BIT ASSIGNMENTS & CONSTANTS 00257 ;********************************************************* 0000000D 00258 CR EQU 0x0D ;ASCII CARRIER RETURN 00000020 00259 SP EQU 0x20 ;ASCII SPACE 00000002 00260 Z EQU 0x02 ;STATUS, ZERO FLAG 00000000 00261 C EQU 0x00 ;STATUS, CARRY FLAG 00262 ;********************************************************* 00263 ; MACRO ROUTINES 00264 ;********************************************************* 00265 BANK0 MACRO MPASM 02.80 Released GLASS.ASM 11-3-2002 21:23:57 PAGE 6 Thermometer, RTD rev 1.0 LOC OBJECT CODE LINE SOURCE TEXT VALUE 00266 BCF STATUS,5 ;SET REGISTER BANK 0 00267 ENDM 00268 BANK1 MACRO 00269 BSF STATUS,5 ;SET REGISTER BANK 1 00270 ENDM 00271 PAAGE0 MACRO 00272 CLRF PCLATH ;SELECT 1ST PAGE 00273 ENDM 00274 PUSH MACRO 00275 BCF INTCON,7 ;DISABLE ALL IRQ 00276 BCF INTCON,6 00277 MOVWF IWREG ;AFFECTS ZERO FLAG, STORE WORKING REG 00278 SWAPF STATUS,W ;IF IT WAS ZERO IT'S STILL ZERO. 00279 MOVWF ISTAT ;DUPLICATE REG IN BANK 0 & 1 00280 BCF STATUS,Z ;PRE-CLR ZERO STATUS BIT 00281 BTFSC STATUS,5 ;SET = BANK1 00282 BSF STATUS,Z ;SET = WE WERE IN BANK 1 WHEN INTERRUPTED 00283 BANK0 00284 BCF DEGCF,5 ;PRE-CLEAR AS => WAS IN BANK0 WHEN INTERRUPTED 00285 BTFSC STATUS,Z 00286 BSF DEGCF,5 ;SET = WAS IN BANK 1 WHEN INTERRUPTED 00287 MOVFW PCLATH 00288 MOVWF IPCLAT ;DUPLICATE REG IN BANK 0 & 1 00289 CLRF PCLATH ;6 CYCLES BEFORE CLR 00290 ENDM 00291 ;********************************************************* 00292 ;\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/ 00293 ;/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\ 00294 ; *.*.*.*.*.*.*.*.*.*.*.*.*.*.*.*.*.*.*.*.*.*.*.*.*.*.*.* 00295 ;//////////////// SYSTEM INITIALIZATION \\\\\\\\\\\\\\\\\ 00296 ; *.*.*.*.*.*.*.*.*.*.*.*.*.*.*.*.*.*.*.*.*.*.*.*.*.*.*.* 00297 ;********************************************************* 00298 ; PROGRAM VECTOR ASSIGNMENTS 00299 ;********************************************************* 0000 00300 ORG 0x00 0000 0000 00301 RSTVEC NOP ;GOOD PLACE TO BREAK TO TROUBLESHOOT 0001 2871 00302 GOTO START ;RESET VECTOR 00303 ;///////////////////////////////////////////////////////// 00304 ;********************************************************* 0004 00305 ORG 0x04 ;16C74A'S INT VECTOR 00306 INTVEC PUSH 0004 138B M BCF INTCON,7 ;DISABLE ALL IRQ 0005 130B M BCF INTCON,6 0006 00DF M MOVWF IWREG ;AFFECTS ZERO FLAG, STORE WORKING REG 0007 0E03 M SWAPF STATUS,W ;IF IT WAS ZERO IT'S STILL ZERO. 0008 00DE M MOVWF ISTAT ;DUPLICATE REG IN BANK 0 & 1 0009 1103 M BCF STATUS,Z ;PRE-CLR ZERO STATUS BIT 000A 1A83 M BTFSC STATUS,5 ;SET = BANK1 000B 1503 M BSF STATUS,Z ;SET = WE WERE IN BANK 1 WHEN INTERRUPTED M BANK0 000C 1283 M BCF STATUS,5 ;SET REGISTER BANK 0 000D 12B1 M BCF DEGCF,5 ;PRE-CLEAR AS => WAS IN BANK0 WHEN INTERRUPTED 000E 1903 M BTFSC STATUS,Z MPASM 02.80 Released GLASS.ASM 11-3-2002 21:23:57 PAGE 7 Thermometer, RTD rev 1.0 LOC OBJECT CODE LINE SOURCE TEXT VALUE 000F 16B1 M BSF DEGCF,5 ;SET = WAS IN BANK 1 WHEN INTERRUPTED 0010 080A M MOVFW PCLATH 0011 00DD M MOVWF IPCLAT ;DUPLICATE REG IN BANK 0 & 1 0012 018A M CLRF PCLATH ;6 CYCLES BEFORE CLR 0013 188B 00307 BTFSC INTCON,1 ;SET = EXT INT, RB0 (ON/OFF SW) HAS OCCURRED 0014 282B 00308 GOTO NIGHT 0015 188C 00309 NXINT BTFSC PIR1,1 ;TEST FOR TIMER 2 FLAG 0016 2831 00310 GOTO TIMMR2 ;SERVICE OTHER INTERRUPTS 00311 ; GOTO TTYTYM ;TIMER1 SERVICE ROUTINE 00312 ;********************************************************* 0017 1C0C 00313 TTYTYM BTFSS PIR1,0 ;TEST FOR TIMER 1 FLAG 0018 2821 00314 GOTO POPPER ;NO MORE INTERRUPTS ACTIVE 0019 300B 00315 MOVLW 0x0B ;0BDC = 500ms = TIMMER1 001A 008F 00316 MOVWF TMR1H ;MAY SEED LATER 001B 30DC 00317 MOVLW 0xDC ; 001C 008E 00318 MOVWF TMR1L 001D 100C 00319 BCF PIR1,0 ;CLR TMR1F, TIMER1 INT FLAG 001E 3035 00320 MOVLW 0x35 ;LOADING TIMER CLRS PRESET 001F 0090 00321 MOVWF T1CON ;TIMER1 PRESCALE = 8 0020 100C 00322 BCF PIR1,0 00323 ; GOTO POPPER 00324 ; 0021 085D 00325 POPPER MOVFW IPCLAT ;ALREADY IN BAN0, FROM BANK 0 0022 008A 00326 MOVWF PCLATH ;NOT FOR NOW RESTORE UPPER PC LATCH 0023 1AB1 00327 BTFSC DEGCF,5 ;USED TO ID ORIGINAL BANK PRE-INTERRUPT 0024 1683 00328 BSF STATUS,5 ;SET = WE WERE IN IN BANK 1 WHEN PUSHED 0025 0E5E 00329 SWAPF ISTAT,W ;ISTAT, IWREG ARE DUPLICATED 0026 0083 00330 MOVWF STATUS ; IN BANK1 AS ISTATH & IWREG2 0027 0EDF 00331 SWAPF IWREG,F ;IN SAME LOCATION BUT IN A DIFFERENT BANK 0028 0E5F 00332 SWAPF IWREG,W 0029 170B 00333 BSF INTCON,6 00334 ; BSF INTCON,7 ;DONE BY DEFAULTON INT EXIT, ENABLE GLOBAL INT 002A 0009 00335 RETFIE 00336 002B 018B 00337 NIGHT CLRF INTCON ;READY FOR WAKE UP INTERRUPT 00338 BANK1 002C 1683 M BSF STATUS,5 ;SET REGISTER BANK 1 Message[302]: Register in operand not in bank 0. Ensure that bank bits are correct. 002D 018C 00339 CLRF PIE1 ;DISABLE MOST INTERRUPTS 00340 BANK0 002E 1283 M BCF STATUS,5 ;SET REGISTER BANK 0 002F 1631 00341 BSF DEGCF,4 ;SLEEP STATUS 0030 2821 00342 GOTO POPPER ;RETURN FROM INTERRUPT 00343 ; 0031 0831 00344 TIMMR2 MOVFW DEGCF ;ONLY BO AND B1 VALID 0032 3903 00345 ANDLW 0x03 ;0x02 = DIGIT2, 0x03 = DIGIT1 Message[305]: Using default destination of 1 (file). 0033 0782 00346 ADDWF PCL 0034 2848 00347 GOTO MODE1A ;0x00 COM1 NORMAL 0035 2852 00348 GOTO MODE2A ;0x01 COM2 NORMAL 0036 2862 00349 GOTO MODE1B ;0x02 COM1 COMPLEMENT 00350 ; GOTO MODE2B ;0x03 COM2 COMPLEMENT 00351 ;****************************************************************** MPASM 02.80 Released GLASS.ASM 11-3-2002 21:23:57 PAGE 8 Thermometer, RTD rev 1.0 LOC OBJECT CODE LINE SOURCE TEXT VALUE 00352 ; COM1 & COM2 BACKPLANE VOLTAGE LEVELS 00353 ;****************************************************************** 00354 ; 1K OHM 00355 ;RB4 ----/\/\/\/----| 00356 ; 1K OHM |------- LCD PIN 17 COM1 00357 ;RB5 ----/\/\/\/----| 00358 ; 00359 ; 1K OHM 00360 ;RB6 ----/\/\/\/----| 00361 ; 1K OHM |------- LCD PIN 1 COM2 00362 ;RB7 ----/\/\/\/----| 00363 ;****************************************************************** 00364 ;__________________________________________________________________ 00365 ;WEIGHT| 8 | 4 | 2 | 1 |___________________________| 00366 ; PIN | RB7 | RB6 | RB5 | RB4 | COM1 | COM2 | HEX | 00367 ; MODE | COM2B | COM2A | COM1B | COM1A | VOLTAGE | VOLTAGE | VALUE | 00368 ;------|-------|-------|-------|-------|---------|---------|-------| 00369 ; 1A | 0 | 1 | INPUT | 1 | 3.8 | 1.9 | 5 | 00370 ;------|-------|-------|-------|-------|---------|---------|-------| 00371 ; 2A | INPUT | 1 | 0 | 1 | 1.9 | 3.8 | 5 | 00372 ;------|-------|-------|-------|-------|---------|---------|-------| 00373 ; 1B | 0 | 1 | INPUT | 0 | 0 | 1.9 | 4 | 00374 ;------|-------|-------|-------|-------|---------|---------|-------| 00375 ; 2B | INPUT | 0 | 0 | 1 | 1.9 | 0 | 1 | 00376 ;------------------------------------------------------------------ 00377 ;******************************************************************* 00378 ; 00379 ;ALTERNATE DISPLAY VERIFIED 00380 ;__________________________________________________________________ 00381 ;WEIGHT| 8 | 4 | 2 | 1 |___________________________| 00382 ; PIN | RB7 | RB6 | RB5 | RB4 | COM2 | COM1 | HEX | 00383 ; MODE | COM1B | COM1A | COM2B | COM2A | VOLTAGE | VOLTAGE | VALUE | 00384 ;------|-------|-------|-------|-------|---------|---------|-------| 00385 ; 1A | 0 | 1 | INPUT | 1 | 5 | 2.5 | 5 | 00386 ;------|-------|-------|-------|-------|---------|---------|-------| 00387 ; 2A | INPUT | 1 | 0 | 1 | 2.5 | 5 | 5 | 00388 ;------|-------|-------|-------|-------|---------|---------|-------| 00389 ; 1B | 0 | 1 | INPUT | 0 | 0 | 2.5 | 4 | 00390 ;------|-------|-------|-------|-------|---------|---------|-------| 00391 ; 2B | INPUT | 0 | 0 | 1 | 2.5 | 0 | 1 | 00392 ;------------------------------------------------------------------ 00393 ;******************************************************************* 00394 ;NEED 4 PASSES 00395 ;a) BOTTOM OF ALL CHARACTERS, COM1A HI BYTE (HCOM1A) & LO BYTE (LCOM1A) 00396 ;b) TOP OF ALL CHARACTERS, COM1A HI BYTE (HCOM2A) & LO BYTE (LCOM2A) 00397 ;c) BOTTOM OF ALL CHARACTERS, COMPLEMENTED COM1A HI BYTE (HCOM1A -N) & 00398 ; LO BYTE (LCOM1A -N) 00399 ;d) TOP OF ALL CHARACTERS, COM1A HI BYTE (HCOM2A -N) & LO BYTE (LCOM2A -N) 00400 ; 0037 3006 00401 MODE2B MOVLW 0x06 Message[305]: Using default destination of 1 (file). 0038 07AB 00402 ADDWF BATCNT ;USED IN BATTERY LO ROUTINE TO BLINK DISPLAY 0039 1031 00403 BCF DEGCF,0 ;PRESET FOR NEXT PASS 0x00 MODE1A MPASM 02.80 Released GLASS.ASM 11-3-2002 21:23:57 PAGE 9 Thermometer, RTD rev 1.0 LOC OBJECT CODE LINE SOURCE TEXT VALUE 003A 10B1 00404 BCF DEGCF,1 ;COM2B 003B 0936 00405 COMF HCOM2A,W ;FD COMPLEMENT THE DATA 003C 0088 00406 MOVWF PORTD 003D 0937 00407 COMF LCOM2A,W ;DC 003E 0087 00408 MOVWF PORTC 00409 BANK1 003F 1683 M BSF STATUS,5 ;SET REGISTER BANK 1 Message[302]: Register in operand not in bank 0. Ensure that bank bits are correct. 0040 1286 00410 BCF TRISB,5 ;MAKE IT AN OUTPUT 00411 BANK0 0041 1283 M BCF STATUS,5 ;SET REGISTER BANK 0 0042 1306 00412 BCF PORTB,6 00413 BANK1 0043 1683 M BSF STATUS,5 ;SET REGISTER BANK 1 Message[302]: Register in operand not in bank 0. Ensure that bank bits are correct. 0044 1786 00414 BSF TRISB,7 ;RB7 IS HI MAKE RB7 INPUT, HI-Z 00415 BANK0 0045 1283 M BCF STATUS,5 ;SET REGISTER BANK 0 0046 1606 00416 BSF PORTB,4 0047 285E 00417 GOTO BYELCD 00418 ; 0048 1431 00419 MODE1A BSF DEGCF,0 ;PRESET FOR NEXT PASS 0x01 MODE2A 0049 10B1 00420 BCF DEGCF,1 ; 004A 0834 00421 MOVFW HCOM1A ;98 DATA NORMAL 004B 0088 00422 MOVWF PORTD 004C 0835 00423 MOVFW LCOM1A ;08 004D 0087 00424 MOVWF PORTC 00425 BANK1 004E 1683 M BSF STATUS,5 ;SET REGISTER BANK 1 Message[302]: Register in operand not in bank 0. Ensure that bank bits are correct. 004F 1686 00426 BSF TRISB,5 ;MAKE RB5 INPUT, HI-Z Message[302]: Register in operand not in bank 0. Ensure that bank bits are correct. 0050 1386 00427 BCF TRISB,7 ;MAKE IT AN OUTPUT, IT SHOULD ALREADY BE RB7=LO 0051 285B 00428 GOTO UTILX 00429 ; 0052 1031 00430 MODE2A BCF DEGCF,0 ;PRESET FOR NEXT PASS 0x02 MODE1B 0053 14B1 00431 BSF DEGCF,1 0054 0836 00432 MOVFW HCOM2A ;02 DATA NORMAL 0055 0088 00433 MOVWF PORTD 0056 0837 00434 MOVFW LCOM2A ;23 0057 0087 00435 MOVWF PORTC 00436 BANK1 0058 1683 M BSF STATUS,5 ;SET REGISTER BANK 1 Message[302]: Register in operand not in bank 0. Ensure that bank bits are correct. 0059 1786 00437 BSF TRISB,7 ;MAKE RB5 INPUT, HI-Z Message[302]: Register in operand not in bank 0. Ensure that bank bits are correct. 005A 1286 00438 BCF TRISB,5 ;MAKE IT AN OUTPUT, IT SHOULD ALREADY BE RB7=LO 00439 UTILX BANK0 005B 1283 M BCF STATUS,5 ;SET REGISTER BANK 0 005C 1606 00440 BSF PORTB,4 005D 1706 00441 BSF PORTB,6 005E 1386 00442 BYELCD BCF PORTB,7 ; 005F 1286 00443 BCF PORTB,5 MPASM 02.80 Released GLASS.ASM 11-3-2002 21:23:57 PAGE 10 Thermometer, RTD rev 1.0 LOC OBJECT CODE LINE SOURCE TEXT VALUE 0060 108C 00444 BCF PIR1,1 ;CLR TMR2IF, TIMER2 INT FLAG 0061 2821 00445 GOTO POPPER ;RETURN FROM INTERRUPT 00446 ; 0062 1431 00447 MODE1B BSF DEGCF,0 ;PRESET FOR NEXT PASS 0x03 MODE2B 0063 14B1 00448 BSF DEGCF,1 ; 0064 0934 00449 COMF HCOM1A,W ;67 COMPLEMENT THE DATA 0065 0088 00450 MOVWF PORTD 0066 0935 00451 COMF LCOM1A,W ;F7 COMPLEMENTING BOTTOM HALF OF CHARACTERS 0067 0087 00452 MOVWF PORTC 00453 BANK1 0068 1683 M BSF STATUS,5 ;SET REGISTER BANK 1 Message[302]: Register in operand not in bank 0. Ensure that bank bits are correct. 0069 1386 00454 BCF TRISB,7 ;MAKE IT AN OUTPUT 00455 BANK0 006A 1283 M BCF STATUS,5 ;SET REGISTER BANK 0 006B 1206 00456 BCF PORTB,4 00457 BANK1 006C 1683 M BSF STATUS,5 ;SET REGISTER BANK 1 Message[302]: Register in operand not in bank 0. Ensure that bank bits are correct. 006D 1686 00458 BSF TRISB,5 ;MAKE RB5 INPUT, HI-Z 00459 BANK0 006E 1283 M BCF STATUS,5 ;SET REGISTER BANK 0 006F 1706 00460 BSF PORTB,6 ;ALREADY SET 0070 285E 00461 GOTO BYELCD 00462 ;********************************************************* 00463 ; CONFIGURE I/O's 00464 ;********************************************************* 0071 018B 00465 START CLRF INTCON ;DIS GLOBAL/PERIPH/INT/TIMER PG14 0072 304F 00466 MOVLW 0x4F 0073 00BF 00467 MOVWF BCDTMP ;ADDITIONAL POWER UP DELAY SO LCD CAN BLEED 00468 ; MOVLW HIGH DOIOS ;KEEP INIT ROUTINES IN UPPER MEM 00469 ; MOVWF PCLATH 0074 2171 00470 CALL DOIOS ;INITIALIZE PIC CFG 00471 ; PAAGE0 00472 BANK0 0075 1283 M BCF STATUS,5 ;SET REGISTER BANK 0 0076 3040 00473 MOVLW 0x40 0077 00B2 00474 MOVWF DSPLAY 0078 3000 00475 MOVLW 0x00 ;DISPLAY ZEROES INSTEAD 0079 00B4 00476 MOVWF HCOM1A ;POWER ON DISPLAY ALL SEGMENTS 007A 00B6 00477 MOVWF HCOM2A 007B 00B5 00478 MOVWF LCOM1A 007C 00B7 00479 MOVWF LCOM2A 007D 1732 00480 BSF DSPLAY,6 ;SET = ALL DIGIT STATUS, WERE COMPLETLY PRINTED 00481 ;FOR DEMO ONLY, DON'T PRINT MIMUS SIGN 007E 1731 00482 BSF DEGCF,6 ;CLR = PRINT MINUS SIGN = WAS DEFAULT 00483 ;********************************************************* 00484 ; \/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/ 00485 ; /\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\ 00486 ;*.*.*.*.*.*.*.*.*.*.*.*.*.*.*.*.*.*.*.*.*.*.*.*.*.*.*.*.* 00487 ; OPERATING PROGRAM & ALGORYTHM 00488 ;*.*.*.*.*.*.*.*.*.*.*.*.*.*.*.*.*.*.*.*.*.*.*.*.*.*.*.*.* 00489 ;********************************************************* MPASM 02.80 Released GLASS.ASM 11-3-2002 21:23:57 PAGE 11 Thermometer, RTD rev 1.0 LOC OBJECT CODE LINE SOURCE TEXT VALUE 007F 018A 00490 RUN CLRF PCLATH ;ARE WE GOING TO SLEEP? 0080 1E31 00491 BTFSS DEGCF,4 ;SET = IN SLEEP MODE 0081 289E 00492 GOTO BATEST ;TEST BATTERY 00493 BANK1 0082 1683 M BSF STATUS,5 ;SET REGISTER BANK 1 Message[302]: Register in operand not in bank 0. Ensure that bank bits are correct. 0083 018C 00494 CLRF PIE1 ;DISABLE MOST INTERRUPTS 0084 30FF 00495 MOVLW 0xFF Message[302]: Register in operand not in bank 0. Ensure that bank bits are correct. 0085 0086 00496 MOVWF TRISB ;NOTE PREVIOUS CLRF PORTB, ALL LINE TO LCD ARE LO Message[302]: Register in operand not in bank 0. Ensure that bank bits are correct. 0086 0088 00497 MOVWF TRISD Message[302]: Register in operand not in bank 0. Ensure that bank bits are correct. 0087 0087 00498 MOVWF TRISC Message[302]: Register in operand not in bank 0. Ensure that bank bits are correct. 0088 1685 00499 BSF TRISA,5 ;CHANGE TO INPUT FOR CURRENT CONSUMPTION 00500 BANK0 0089 1283 M BCF STATUS,5 ;SET REGISTER BANK 0 008A 018C 00501 CLRF PIR1 ;ALL FLAG ARE CLEARED 008B 1085 00502 BCF PORTA,1 ;CONVST=LO 5.5us REQUIRED FOR SAMPLING 008C 1505 00503 BSF PORTA,2 ;SHUT DOWN ANALOG POWER SUPPLIES 008D 1112 00504 BCF T2CON,2 ;TURN TIMER2 OFF 008E 1010 00505 BCF T1CON,0 ;TURN TIMER1 OFF 008F 2096 00506 CALL DELAY 0090 2096 00507 CALL DELAY 0091 3050 00508 MOVLW 0x50 ;NO GIE (INTCON,7 BUT MUST HAVE PERIPHERAL 00509 ; ;ENABLE INTERRUPT & EXT INT ENABLE BIT 00510 ; ;TO WAKEUP FROM EXT INT. 0092 008B 00511 MOVWF INTCON ;WILL CONTINUE WITH INSTRUCTIONS FOLLOWING "SLEEP" 0093 0063 00512 SLEEP 0094 0000 00513 NOP 0095 2800 00514 GOTO RSTVEC ;1ST INSTRUCTION AFTER AWAKE FROM SLEEP! 00515 ;RESTART UNIT 00516 ; 0096 018A 00517 DELAY CLRF PCLATH 0097 30FF 00518 MOVLW 0xFF ;USED AS DEBOUCE TIMING 0098 00AA 00519 MOVWF TEMP1 ;ABOUT 200ms Message[305]: Using default destination of 1 (file). 0099 0BBF 00520 WEIST DECFSZ BCDTMP 009A 2899 00521 GOTO WEIST ;READY FOR WAKE UP INTERRUPT Message[305]: Using default destination of 1 (file). 009B 0BAA 00522 DECFSZ TEMP1 009C 2899 00523 GOTO WEIST 009D 0008 00524 RETURN 00525 ;********************************************************* 00526 ;OMITTED FOR THIS DEMO TESTING THE BATTERY 00527 ;********************************************************* 009E 00528 BATEST 00529 ; BTFSC PORTE,2 ; 00530 ; GOTO BATOK 00531 ;BATLOW MOVFW BATCNT ;WAS 0x20 00532 ; SUBLW 0x7F ;THAT'S 0x80 - BATCNT 00533 ; BTFSC STATUS,C ;SET = W > BATCNT MPASM 02.80 Released GLASS.ASM 11-3-2002 21:23:57 PAGE 12 Thermometer, RTD rev 1.0 LOC OBJECT CODE LINE SOURCE TEXT VALUE 00534 ; GOTO BLINK 00535 ; MOVLW 0x01 ;ALPHA b & A 00536 ; MOVWF HCOM1A 00537 ; MOVLW 0x71 ;DON'T PRINT DP 00538 ; MOVWF HCOM2A ;DON'T PRINT K 00539 ; MOVLW 0xF9 ;ALPHA "t" 00540 ; MOVWF LCOM1A 00541 ; MOVLW 0xFD ; 00542 ; MOVWF LCOM2A 00543 ;BYLOW BSF DSPLAY,4 ;INDICATES A NEW VALUE IS AVAILABLE 00544 ; GOTO RUN 00545 ; 00546 ;BLINK MOVLW 0xFF ;BATTERY LOW INDICATION FLASH 00547 ; MOVWF LCOM1A 00548 ; MOVWF LCOM2A 00549 ; MOVWF HCOM1A 00550 ; MOVWF HCOM2A 00551 ; GOTO BYLOW 00552 ; 009E 00553 BATOK 00554 ; BTFSS PORTB,2 ;CIRCUIT WHICH MONITORS THE BATTERY 00555 ; GOTO UUTING 009E 1A31 00556 BTFSC DEGCF,4 ;SET = WILL BE GOING IN SLEEP MODE 009F 28BD 00557 GOTO UUTING 00A0 1410 00558 BSF T1CON,0 ;ENABLE TIMER1 00559 BANK1 00A1 1683 M BSF STATUS,5 ;SET REGISTER BANK 1 Message[302]: Register in operand not in bank 0. Ensure that bank bits are correct. 00A2 140C 00560 BSF PIE1,0 ;ENABLE TIMER1 INTERRUPT 00561 BANK0 00A3 1283 M BCF STATUS,5 ;SET REGISTER BANK 0 00562 ; CALL A2DDMP ;TRANSMIT TEMPERATURE VALUE TO DATA LOG 00A4 28C1 00563 GOTO OUTING 00564 ;********************************************************* 00565 ; LCD CHARACTER TABLE FOR COM1 00566 ;MAKE SURE YOU DON'T CROSS BOUNDRIES HERE! 00567 ;SPECIAL NOTE: DO COMF INSTRUCTION OF THIS TABLE FOR COM2 TABLE 00568 ;********************************************************* Message[305]: Using default destination of 1 (file). 00A5 0782 00569 LCDMAP ADDWF PCL ;THIS IS AT BEGINING OF 1ST PAGE! 00A6 3440 00570 RETLW 0x40 ; 0 0 HI NIBBLE = COM1, LO NIBBLE = COM2 00A7 34DC 00571 RETLW 0xDC ; 1 1 00A8 3428 00572 RETLW 0x28 ; 2 2 00A9 3488 00573 RETLW 0x88 ; 3 3 00AA 3494 00574 RETLW 0x94 ; 4 4 00AB 3482 00575 RETLW 0x82 ; 5 5 00AC 3402 00576 RETLW 0x02 ; 6 6 00AD 34D8 00577 RETLW 0xD8 ; 7 7 00AE 3400 00578 RETLW 0x00 ; 8 8 00AF 3490 00579 RETLW 0x90 ; 9 9 00B0 3410 00580 RETLW 0x10 ; A 00B1 3406 00581 RETLW 0x06 ; b 00B2 342E 00582 RETLW 0x2E ; c MPASM 02.80 Released GLASS.ASM 11-3-2002 21:23:57 PAGE 13 Thermometer, RTD rev 1.0 LOC OBJECT CODE LINE SOURCE TEXT VALUE 00B3 3422 00583 RETLW 0x22 ; E 00B4 3432 00584 RETLW 0x32 ; F 00B5 3480 00585 RETLW 0x80 ; g 00B6 3416 00586 RETLW 0x16 ; h 00B7 34DE 00587 RETLW 0xDE ; i 00B8 340E 00588 RETLW 0x0E ; o 00B9 3430 00589 RETLW 0x30 ; P 00BA 3436 00590 RETLW 0x36 ; t 00BB 344E 00591 RETLW 0x4E ; u 00BC 34FC 00592 RETLW 0xFC ;BLANK DIGIT 00593 ; 00594 UUTING BANK1 00BD 1683 M BSF STATUS,5 ;SET REGISTER BANK 1 Message[302]: Register in operand not in bank 0. Ensure that bank bits are correct. 00BE 100C 00595 BCF PIE1,0 ;DISABLE TIMER1 INTERRUPT 00596 BANK0 00BF 1283 M BCF STATUS,5 ;SET REGISTER BANK 0 00C0 1010 00597 BCF T1CON,0 ;DISABLE TIMER1 00C1 1E05 00598 OUTING BTFSS PORTA,4 ;HAS 10OK PULL DOWN, SET = TOGGLE Deg C/F 00C2 28CA 00599 GOTO RDA2D ; 00C3 1A05 00600 GETOFF BTFSC PORTA,4 ;LOOK FOR KEY RELEASE 00C4 28C3 00601 GOTO GETOFF ;WAITING FOR SWITCH TO BE RELEASED 00C5 1BB1 00602 TOGGLE BTFSC DEGCF,7 00C6 28C9 00603 GOTO FME 00C7 17B1 00604 BSF DEGCF,7 ;DEG F 00C8 28CA 00605 GOTO RDA2D 00C9 13B1 00606 FME BCF DEGCF,7 ;DEG C 00607 ; GOTO RDA2D 00608 ;********************************************************* 00609 ;EXAMPLE 91.0 Deg C = 195.8 Deg F 00610 ;********************** 00611 ;1.0 IS UNITS FROM THE LOCKUP TABLE 00612 ;9 IS HUNDREDS AND WAS PRE-EVALUATED FROM THE A/D RAW DATA RESULTS DUE TO 00613 ;IT'S VALUE IN THE DECADE RANGE. SO AT THE A/D PROCESS WE STORED NUMERICAL 9 00614 ;IN A MULTI-PURPOSE REGISTER CALLED DIGTLO. 00615 ; 00616 ;IN OTHER WORDS ALL THAT'S INCLUDES IN MY LOOKUP TABLE IS THE UNITS (STORED AS UNIT * 10) 00617 ;THIS SCHEME MAKES MY TABLE SHORTER AND OFFER MUCH MORE POINTS. THE TABLE 00618 ;INCREMENT AT 0.1 DEGREE. SO TO RECOMPOSE MY VALUE, (9 * 100), THEN ADD (1.0 * 10) 00619 ;WHICH FINALLY RESULTS AS 910. WITH EXTREME ACCURACY THE NUMBER IS 00620 ;MATHEMATICALLY CONVERTED WITH A ROUTINE CALLED C2F (OMITTED HERE FOR DEMO) 00621 ;WHICH RESULTS IN Deg F WITH A VALUE IN THIS CASE OF 19580 OR 4C7C WHICH 00622 ;REALLY REPRESENTS 195.8 Deg F. THIS SAME C2F ROUTINE FULLY SUPPORTS 00623 ;NEGATIVE TEMPERATURE VALUES ALSO. 00624 ;FROM THE BDC ROUTINE I SHOULD HAVE 00625 ; 1 5 9 0 8 00626 ;DCIML0-->;FIRST DIGIT ;DCIML1-->;DIGIT 3 & 2 ;DCIML2-->;DIGIT 5 & 4 00627 ; ;LO NIB ;HI NIB & LO NIB ;HI NIB & LO NIB 00628 ; 00629 ;*******NOTE CAREFULLY! THE LAST NIBBLE OF DCIML2 IS NOT UTILIZED SINCE THE VALUES 00630 ;*******WHERE ORIGINALLY MULTIPLY BE 10.0 AS SEEN ABOVE AS SHOULD ALWAYS BE ZERO. 00631 ; 00632 ;********************************************************* MPASM 02.80 Released GLASS.ASM 11-3-2002 21:23:57 PAGE 14 Thermometer, RTD rev 1.0 LOC OBJECT CODE LINE SOURCE TEXT VALUE 00633 ;THE FOLLOWING SMALL TEST ROUTINE SIMULATES: A/D OF RAW RTD, DECADE 00634 ;AND HUNDRED STORAGE, UNIT PART OF THE NUMBER TABLE LOOKUP, THEN COMPOSING 00635 ;THE RESULTING Deg C VALUE, AND CONVERTING THIS Deg C VALUE TO Deg F 00636 ;PRECISELY DUE TO USER'S DEPRESSION OF THE Deg C/F MOMEMTARY SWITCH FEATURE. 00637 ;********************************************************* 00CA 304C 00638 RDA2D MOVLW 0x4C ;TEST VALUE, 91 Deg C or 195.8 Deg F 00CB 00BD 00639 MOVWF HBYTE 00CC 307C 00640 MOVLW 0x7C 00CD 00BE 00641 MOVWF LBYTE 00642 ;********************************************************* 00643 ; CONVERSION OF 2 HEX BYTES (65536 MAX) TO 5 DIGIT 00644 ; BCD NUMBERS WHERE DCIML0 = MSD. Mem= 29, CYCLES = 776 00645 ; WREG0,DCIML0,DCIML1,DCIML2,HBYTE,LBYTE MUST BE IN SEQUENCIAL ORDER 00646 ; IN REGISTER MAP. BCDTMP IS PREVIOUSLY PRELOADED WITH 16.0 00647 ;********************************************************* 00CE 3010 00648 BCD MOVLW 0x10 ;16.0 00CF 00BF 00649 MOVWF BCDTMP ;PRELOAD TMP REG 00D0 01BC 00650 CLRF DCIML2 ;DIGIT 4 & 5 00D1 01BB 00651 CLRF DCIML1 ;DIGIT 3 & 2 00D2 01BA 00652 CLRF DCIML0 ;FIRST DIGIT 00D3 1003 00653 BCF STATUS,C ;CONDITION CARRY Message[305]: Using default destination of 1 (file). 00D4 0DBE 00654 BCDLP RLF LBYTE ;LSB HEX Message[305]: Using default destination of 1 (file). 00D5 0DBD 00655 RLF HBYTE ;MSB HEX Message[305]: Using default destination of 1 (file). 00D6 0DBC 00656 RLF DCIML2 ;DIGIT 5 & 4 Message[305]: Using default destination of 1 (file). 00D7 0DBB 00657 RLF DCIML1 ;DIGIT 3 & 2 Message[305]: Using default destination of 1 (file). 00D8 0DBA 00658 RLF DCIML0 ;FIRST DIGIT 00D9 1103 00659 CLRZ Message[305]: Using default destination of 1 (file). 00DA 0BBF 00660 DECFSZ BCDTMP ;=DCFSNZ TO MORBCD 00DB 28DD 00661 GOTO MORBCD 00DC 28F1 00662 GOTO ENDBCD ; 00DD 303A 00663 MORBCD MOVLW DCIML0 ; 00DE 0084 00664 MOVWF FSR ;0x3A DCIML0'S ADDRESS TO FSR 00DF 0800 00665 ADJBCD MOVFW INDF ;ADJUST DCIML2 TO BCD 00E0 3E03 00666 ADDLW 0x03 ;CHECKING LS NIBBLE 00E1 00B9 00667 MOVWF WREG0 ;W VALUE = BCDTMP VALUE 00E2 19B9 00668 BTFSC WREG0,3 ;IS 4TH DIGIT > 7 00E3 0080 00669 MOVWF INDF ;SAVE AS 4TH DIGIT 00E4 0800 00670 MOVFW INDF ;INDF = ORGINAL INDF OR ORGINAL INDF + 0x03 00E5 3E30 00671 ADDLW 0x30 ;CHECKING MS NIBBLE 00E6 00B9 00672 MOVWF WREG0 ;W VALUE = BCDTMP VALUE 00E7 1BB9 00673 BTFSC WREG0,7 ;IS 5TH DIGIT > 7 00E8 0080 00674 MOVWF INDF ;SAVE AS 5TH DIGIT Message[305]: Using default destination of 1 (file). 00E9 0A84 00675 INCF FSR ;CONTINUE CONVERSION WITH NEXT 00EA 303D 00676 MOVLW HBYTE ; HEX BYTE 00EB 1003 00677 CLRC 00EC 1103 00678 CLRZ ; MPASM 02.80 Released GLASS.ASM 11-3-2002 21:23:57 PAGE 15 Thermometer, RTD rev 1.0 LOC OBJECT CODE LINE SOURCE TEXT VALUE 00ED 0204 00679 SUBWF FSR,W ; 00EE 1903 00680 BTFSC STATUS,Z ;CHECKING IF DCIML2 (DIGIT 4 & 5) 00EF 28D4 00681 GOTO BCDLP ;HBYTE IS = & NOT BIGGER THAN FSR 00F0 28DF 00682 GOTO ADJBCD ;HYBYTE IS BIGGER THAN FSR 00683 ; 00F1 1F32 00684 ENDBCD BTFSS DSPLAY,6 ;SET = ALL DIGIT WERE COMPLETLY PRINTED 00F2 287F 00685 GOTO RUN ; 00686 ; 00687 ;DO WE HAVE TIME TO UPDATE THE LCD DATA BUFFERS BEFORE THE TIMER EXPIRES????? 00688 ;********************************************************* 00689 ; DATA REFRESH RATE 00690 ;********************************************************* 00F3 0811 00691 TYMEOK MOVFW TMR2 ;THAT'S 0x1D - PR2. NEED ABOUT 100us TO LOAD LCD BUFFERS 00F4 3C1C 00692 SUBLW 0x1C ;(ONE LESS) = 0x1D = 19.0 = PR2 SEED 00F5 1C03 00693 BTFSS STATUS,C ;MAKE SURE YOU HAVE TIME BEFORE LCD NEEDS UPDATE 00F6 287F 00694 GOTO RUN ;NO TIME TO RISK UPDATE, NEED ABOUT Message[305]: Using default destination of 1 (file). 00F7 0BDC 00695 DECFSZ SLOW ;LCD DATA REFRESH RATE 00F8 287F 00696 GOTO RUN ;INCR OR DECR TO CONTROL LCD DATA REFRESH TIME 00F9 302F 00697 MOVLW 0x2F ;WE ARE DOING A LOT LESS WORK IN THIS DEMO! 00FA 00DC 00698 MOVWF SLOW ;WAS 0x2F IN FULL PROGRAM! 50ms MINIMUM 00FB 083A 00699 MOVFW DCIML0 ;FROM BCD ROUTINE, BCD FIRST DIGIT 00FC 00AC 00700 MOVWF DCML0 ;LCD TABLE READY BUFFERS 00FD 083B 00701 MOVFW DCIML1 ;FROM BCD ROUTINE, BCD DIGIT 2 & 3 00FE 00AD 00702 MOVWF DCML1 ;LCD TABLE READY BUFFERS 00FF 00A0 00703 MOVWF HIBYTE ;ALSO READY FOR COMM IN DEG C ONLY 0100 083C 00704 MOVFW DCIML2 ;FROM BCD ROUTINE, BCD DIGIT 4 & 5 0101 00AE 00705 MOVWF DCML2 ;LCD TABLE READY BUFFERS 0102 00A1 00706 MOVWF LOBYTE ;ALSO READY FOR COMM IN DEG C ONLY 00707 ; 00708 ;LOADING GLASS REGISTERS LOADING GLASS REGISTERS LOADING GLASS REGISTERS 00709 ;LOADING GLASS REGISTERS LOADING GLASS REGISTERS LOADING GLASS REGISTERS 00710 ; 00711 ;PREPARING ACTUAL LCD DATA DERIVED 00712 ;FROM BCD TO LCD TABLE READY BUFFERS TO DATA READY FOR I/O PINS. 00713 ;MUST FILL ORDERL & ORDERH REGISTERS WITH 14 BITS OF DATA FOR I/O PINS TO LCD 00714 ;WITH K, 1ST DIGIT, 2ND DIGIT, DECIMAL POINT DIGIT, ICONS (DP, - SIGN, Deg C or F) 00715 ;SPECIAL NOTES:IN THIS APPLICATION THE MOST SIGNIFICANT DIGIT IS ALWAYS 1.0 OR 0.0. 00716 ;(AGAIN) THE VALUE OFFERED TO THE BCD ROUTING WAS PREVIOUSLY MULTIPLIED 00717 ; BY 100.0. SO 1958 LOOK LIKE 19580. (19580 SIGNIFIES 195.8) 00718 ; 00719 ;IN THIS APPLICATION THE 1ST NUMERIC DOES NOT REQUIRE A SPOT IN THE LCD MAP LOOKUP 00720 ;TABLE SINCE IT IS "K" SEGMENT ON THE DISPLAY. IT'S EASIER TO HANDLE IT MANUALLY. 00721 ;******************************************************************* 00722 ;COM1A COM1A COM1A COM1A COM1A COM1A COM1A COM1A COM1A COM1A COM1A 00723 ;UPPER NIBBLE UPPER NIBBLE UPPER NIBBLE UPPER NIBBLE UPPER NIBBLE 00724 ;WILL BE USING HERE, BCD REGs AS GENERAL PURPOSE REGs/BUFFERS 00725 ;BDCTMP INTO HCOM1A 00726 ;DCMIL0 INTO HCOM2A 00727 ;DCMIL1 INTO LCOM1A 00728 ;DCMIL2 INTO LCOM2A 00729 ;******************************************************************* 0103 01B3 00730 DIG1ME CLRF LEADG0 ;USING 19580 Deg F AS EXAMPLE MPASM 02.80 Released GLASS.ASM 11-3-2002 21:23:57 PAGE 16 Thermometer, RTD rev 1.0 LOC OBJECT CODE LINE SOURCE TEXT VALUE 0104 0E2D 00731 SWAPF DCML1,W ;GET THE "9" 0105 390F 00732 ANDLW 0x0F 0106 20A5 00733 CALL LCDMAP ;HI NIBBLE SEARCH IN HI NIBBLE RESULT 0107 00B0 00734 MOVWF LCDTMP 0108 3040 00735 MOVLW 0x40 0109 0230 00736 SUBWF LCDTMP,W 010A 1903 00737 BTFSC STATUS,Z ;SET = 0 010B 14B3 00738 BSF LEADG0,1 ;LEADING ZERO STATUS 010C 0830 00739 KTHER MOVFW LCDTMP 010D 39F0 00740 ANDLW 0xF0 ;MASK HI NIBBLE 010E 00BF 00741 MOVWF BCDTMP ;STORE IN HCOM1A LATER 00742 ; 010F 0E30 00743 SWAPF LCDTMP,W 0110 39F0 00744 ANDLW 0xF0 0111 00BA 00745 D1IS0 MOVWF DCIML0 ;C0 STORE IN HCOM2A LATER 00746 ; 0112 082D 00747 DIG2ME MOVFW DCML1 ;GET THE "5" 0113 390F 00748 ANDLW 0x0F 0114 20A5 00749 CALL LCDMAP 0115 00B0 00750 MOVWF LCDTMP 0116 3040 00751 MOVLW 0x40 0117 0230 00752 SUBWF LCDTMP,W 0118 1903 00753 BTFSC STATUS,Z ;SET = 0 0119 1533 00754 BSF LEADG0,2 ;LEADING ZERO STATUS 011A 0E30 00755 SWAPF LCDTMP,W 011B 390F 00756 ANDLW 0x0F Message[305]: Using default destination of 1 (file). 011C 04BF 00757 IORWF BCDTMP ;STORE IN HCOM1A LATER 00758 ; 011D 0830 00759 MOVFW LCDTMP 011E 390E 00760 ANDLW 0x0E ;0C WAS 0x0F, NOW DEFAULT DP ON Message[305]: Using default destination of 1 (file). 011F 04BA 00761 IORWF DCIML0 ;STORE IN HCOM2A LATER 00762 ; 0120 0E2E 00763 DIG3ME SWAPF DCML2,W ;GET THE "8" 0121 390F 00764 ANDLW 0x0F ;HI NIBBLE SEARCH IN HI NIBBLE RESULT 0122 20A5 00765 CALL LCDMAP 0123 00B0 00766 MOVWF LCDTMP 0124 390E 00767 ANDLW 0x0E ;UPPER NIBBLE IS CLEARED 0125 00BC 00768 MOVWF DCIML2 ;STORE IN LCOM2A LATER 00769 ; 0126 0E30 00770 SWAPF LCDTMP,W 0127 390F 00771 ANDLW 0x0F ;UPPER NIBBLE IS CLEARED 0128 00BB 00772 MOVWF DCIML1 ;STORE IN LCOM1A LATER 00773 ; 0129 123A 00774 KME BCF DCIML0,4 ;PRECLR K AS NO K, STORE IN HCOM2A LATER 012A 082C 00775 MOVFW DCML0 ;GET THE "1" (IN DIGIT 1 COM2 SECTION OF CHARACTER MAP) 012B 1D03 00776 BTFSS STATUS,Z ;SET = DCML0 = 0 012C 292F 00777 GOTO SIGNME 012D 163A 00778 BSF DCIML0,4 ;NO K, STORE IN HCOM2A LATER 012E 1433 00779 BSF LEADG0,0 ;LEADING ZERO STATUS 012F 00780 SIGNME 00781 ;ALREADY CLEARED ABOVE BCF LCOM2A,0 MPASM 02.80 Released GLASS.ASM 11-3-2002 21:23:57 PAGE 17 Thermometer, RTD rev 1.0 LOC OBJECT CODE LINE SOURCE TEXT VALUE 012F 1B31 00782 BTFSC DEGCF,6 ;CLR = PRINT MINUS SIGN = DEFAULT 00783 ; 00784 ;TEST OF OLD GLASS. HERE WE PRETEND THAT THE COLON SEGMENT IS THE MINUS SEGMENT 00785 ;SINCE THIS OLD GLASS IS NOT CUTOMIZED FOR THE MINUS SIGN YET! NEW GLASS ON THE WAY 00786 ; 0130 143C 00787 BSF DCIML2,0 ;SET = DON'T PRINT MINUS SIGN, PRINT COLON INSTEAD FOR NOW 00788 ; ;STORE IN LCOM2A LATER 0131 123C 00789 WHYEME BCF DCIML2,4 ;PRINT DEGREE OR Y ALWAYS FOR THIS APPLICATION 0132 00790 FORCME ;STORE IN LCOM2A LATER 00791 ;;;ALREADY CLEARED ABOVE BCF LCOM2A,4 ;NO DEGREE OR Y 0132 1BB1 00792 BTFSC DEGCF,7 ;SET = DISPLAY Deg F 0133 2936 00793 GOTO FFYNG 0134 16BC 00794 BSF DCIML2,5 ;2D Z1 OFF, STORE IN LCOM2A LATER 00795 ;;;ALREADY CLEARED ABOVE BCF LCOM1A,5 ;Z2 ON, IS ALREADY AT SET STATUS 0135 2937 00796 GOTO BYDSPL 00797 ; 0136 16BB 00798 FFYNG BSF DCIML1,5 ;Z2 OFF, STORE IN LCOM1A LATER 00799 ;;;ALREADY CLEARED ABOVE BCF LCOM2A,5 ;Z1 ON, IS ALREADY AT SET STATUS 00800 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; 00801 ;;;;;;;;;;;;;;;;;;CHECK LEADING ZEROS;;;;;;;;;;;;;;;;;;;;;;;;; 00802 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; 0137 1C33 00803 BYDSPL BTFSS LEADG0,0 ;SET = WE ARE PRINTING "K", (1) 0138 2944 00804 GOTO BIDSPL 0139 1CB3 00805 BTFSS LEADG0,1 ;SET = FULL DIGIT 1 IS = 0, (9) 013A 2944 00806 GOTO BIDSPL 013B 30F0 00807 MOVLW 0xF0 ;BLANK 1ST DIGIT Message[305]: Using default destination of 1 (file). 013C 04BF 00808 IORWF BCDTMP ;MAKE UPPER NIBBLE = F, STORE IN HCOM1A LATER Message[305]: Using default destination of 1 (file). 013D 04BA 00809 IORWF DCIML0 ;K IS ALREADY SET IF YOUR HERE, STORE IN HCOM2A LATER 013E 1D33 00810 BTFSS LEADG0,2 ;SET = FULL DIGIT 2 IS = 0, (5) 013F 2944 00811 GOTO BIDSPL 0140 300F 00812 MOVLW 0x0F ;BLANK 2ND DIGIT Message[305]: Using default destination of 1 (file). 0141 04BF 00813 IORWF BCDTMP ;MAKE LOWER NIBBLE = F, STORE IN HCOM1A LATER 0142 300E 00814 MOVLW 0x0E ;DON'T TOUCH DP STATUS, ON ALL THE TIME! Message[305]: Using default destination of 1 (file). 0143 04BA 00815 IORWF DCIML0 ;STORE IN HCOM2A LATER 00816 ;DISABLE TIMER2 TEMPORARY TO AVOID ANY LCD FLICKERING FROM WRONG BUFFER DATA 00817 BIDSPL BANK1 0144 1683 M BSF STATUS,5 ;SET REGISTER BANK 1 Message[302]: Register in operand not in bank 0. Ensure that bank bits are correct. 0145 108C 00818 BCF PIE1,1 ;DISABLE TIMER 2 INT 00819 BANK0 0146 1283 M BCF STATUS,5 ;SET REGISTER BANK 0 0147 083F 00820 MOVFW BCDTMP ;TRANSFER BUFFERS 0148 00B4 00821 MOVWF HCOM1A 0149 083A 00822 MOVFW DCIML0 014A 00B6 00823 MOVWF HCOM2A 014B 083B 00824 MOVFW DCIML1 014C 00B5 00825 MOVWF LCOM1A 014D 083C 00826 MOVFW DCIML2 014E 00B7 00827 MOVWF LCOM2A MPASM 02.80 Released GLASS.ASM 11-3-2002 21:23:57 PAGE 18 Thermometer, RTD rev 1.0 LOC OBJECT CODE LINE SOURCE TEXT VALUE 00828 BANK1 014F 1683 M BSF STATUS,5 ;SET REGISTER BANK 1 Message[302]: Register in operand not in bank 0. Ensure that bank bits are correct. 0150 148C 00829 BSF PIE1,1 ;ENABLE TIMER 2 INT 00830 BANK0 0151 1283 M BCF STATUS,5 ;SET REGISTER BANK 0 0152 1632 00831 BSF DSPLAY,4 ;INDICATES A NEW VALUE IS AVAILABLE 0153 287F 00832 GOTO RUN ;DONE 00833 ;********************************************************* 00834 ; TEMPERATURE IS BEYOND SPEC'ED POSITIVE & MINUS RANGES 00835 ;********************************************************* 00836 RNGOUT BANK1 0154 1683 M BSF STATUS,5 ;SET REGISTER BANK 1 Message[302]: Register in operand not in bank 0. Ensure that bank bits are correct. 0155 108C 00837 BCF PIE1,1 ;DISABLE TIMER 2 INT 00838 BANK0 0156 1283 M BCF STATUS,5 ;SET REGISTER BANK 0 0157 3004 00839 MOVLW 0x04 ; 0158 00B4 00840 MOVWF HCOM1A 0159 30FF 00841 MOVLW 0xFF ;NO D.P., NO K 015A 00B6 00842 MOVWF HCOM2A 015B 30F9 00843 MOVLW 0xF9 ;ALPHA "Out" 015C 00B5 00844 MOVWF LCOM1A 015D 30FD 00845 MOVLW 0xFD ;WAS 0D 015E 00B7 00846 MOVWF LCOM2A 00847 BANK1 015F 1683 M BSF STATUS,5 ;SET REGISTER BANK 1 Message[302]: Register in operand not in bank 0. Ensure that bank bits are correct. 0160 148C 00848 BSF PIE1,1 ;ENABLE TIMER 2 INT 00849 BANK0 0161 1283 M BCF STATUS,5 ;SET REGISTER BANK 0 0162 3099 00850 MOVLW 0x99 0163 00A0 00851 MOVWF HIBYTE ;INDICATE OVER TEMP & UNDER TEMP 0164 3090 00852 MOVLW 0x90 0165 00A1 00853 MOVWF LOBYTE 0166 1632 00854 BYOUT BSF DSPLAY,4 ;INDICATES A NEW VALUE IS AVAILABLE 0167 287F 00855 GOTO RUN ;TEMPERATURE OUT OF RANGE INDICATION! 00856 ;********************************************************* 00857 ; DON'T PRINT ICONS FOR WORD MESSAGES 00858 ;********************************************************* 0168 1637 00859 NOICON BSF LCOM2A,4 ;NO DEGREE OR Y 0169 16B5 00860 BSF LCOM1A,5 ;NO Z2 016A 16B7 00861 BSF LCOM2A,5 ;NO Z1 016B 2937 00862 GOTO BYDSPL 00863 ;********************************************************* 00864 ;\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/ 00865 ;///////////////////////////////////////////////////////// 00866 ;********************************************************* 00867 ; GLASS TID-BITS 00868 ;********************************************************* 00869 ;WHEN VCC = 5.0VDC, TO HELP UNDERSTAND THE STATIC CONDITION, 00870 ;WE CAN ALWAYS ASK THE QUESTION: WHAT POTENTIAL IS ACROSS THE 00871 ;SEGEMENT BIT. THE ANSWER WHEN USING TTL/RESISTOR DIVIDER STYLE MPASM 02.80 Released GLASS.ASM 11-3-2002 21:23:57 PAGE 19 Thermometer, RTD rev 1.0 LOC OBJECT CODE LINE SOURCE TEXT VALUE 00872 ;DRIVING IS 2.5V WHILE ON AND 0 WHILE OFF. THIS RULE MUST ALWAYS 00873 ;APPLY. NOTE THAT THE POTENTIAL DIFFERENCE BETWEEN EACH BACKPLANE 00874 ;IS ALWAYS 2.5V. 00875 ; 00876 ;DURING TIMER INTERRUPT, MANAGE FRAME RATE, 1/2 BIAS, 1/2 DC. 00877 ;FRAME RATE = 50Hz; 1/50Hz = 20ms, SO EACH DIGIT REQUIRES TO BE UPDATE 00878 ;EVERY 20MS. 3 1/2 DIGITS AS WELL AS ICON MEANS FOUR SEGMENT COMPLEMENT 00879 ;OR FOUR SECTIONS WHICH NEED TO BE REFRESHED 5ms APART. FOUR BUFFER 00880 ;REGISTERS HOLD THE LCD DATA ALL DERIVED FROM THE TABLE BELOW. EVERY 5ms 00881 ;A DIFFERENT SEGMENT COMPLEMENT GETS UPDATED. TWO BACKPLANES x FOUR SEGMENT 00882 ;COMPLEMENTS. REGISTER NAMES CHOSEN FOR THESE SEGMENT COMPLEMENT BUFFERS ARE 00883 ;LCOM1A, HCOM1A, LCOM2A, HCOM2A 00884 ;NOTE THAT VCC ON THIS LAST DESIGN IS 3.8VDC SO 1/2 BIAS IS 1.9VDC. 00885 ;****************************************************************** 00886 ; DISPLAY CHARACTER BIT [ALSO SEE CHARACTER MAP, (LCDMAP)] 00887 ;****************************************************************** 00888 ; 00889 ; DIGIT1 HI NIB DIGIT1 LO NIB 00890 ; IN IN 00891 ; HCOM1A /\ HCOM2A /\ 00892 ;....................... HI NIB / \ HI NIB / \ 00893 ; (18xXxXx) . ______/COM2\_____ ______/COM1\_____ 00894 ; K & 1ST DIGIT . / \ / \ 00895 ;.......................|---------:---------|:|---------:---------| 00896 ; | LCD PIN# | 4 | 5 | 6 | 3 |:| 4 | 5 | 6 | 3 | 00897 ;...........| BIT | B7 | B6 | B5 | B4 |:| B7 | B6 | B5 | B4 | 00898 ; | PIC-I/O | RD7| RD6| RD5| RD4|:| RD7| RD6| RD5| RD4| 00899 ; DISPLAY | SEGMENT | 1e | 1g | 1c | 1d |:| 1f | 1a | 1b | K | 00900 ; CHARACTER | HEX | | | | |:| | | | | 00901 ;___________|___________|____|____|____|____|:|____|____|____|____| 00902 ; 0 | 0x40 | 0 | 1 | 0 | 0 |:| 0 | 0 | 0 | X | 00903 ;-----------|-----------|-------------------|:|-------------------| 00904 ; 1 | 0xDC | 1 | 1 | 0 | 1 |:| 1 | 1 | 0 | X | 00905 ;-----------|-----------|-------------------|:|-------------------| 00906 ; 2 | 0x28 | 0 | 0 | 1 | 0 |:| 1 | 0 | 0 | X | 00907 ;-----------|-----------|-------------------|:|-------------------| 00908 ; 3 | 0x88 | 1 | 0 | 0 | 0 |:| 1 | 0 | 0 | X | 00909 ;-----------|-----------|-------------------|:|-------------------| 00910 ; 4 | 0x94 | 1 | 0 | 0 | 1 |:| 0 | 1 | 0 | X | 00911 ;-----------|-----------|-------------------|:|-------------------| 00912 ; 5 | 0x82 | 1 | 0 | 0 | 0 |:| 0 | 0 | 1 | X | 00913 ;-----------|-----------|-------------------|:|-------------------| 00914 ; 6 | 0x02 | 0 | 0 | 0 | 0 |:| 0 | 0 | 1 | X | 00915 ;-----------|-----------|-------------------|:|-------------------| 00916 ; 7 | 0xD8 | 1 | 1 | 0 | 1 |:| 1 | 0 | 0 | X | 00917 ;-----------|-----------|-------------------|:|-------------------| 00918 ; 8 | 0x00 | 0 | 0 | 0 | 0 |:| 0 | 0 | 0 | X | 00919 ;-----------|-----------|-------------------|:|-------------------| 00920 ; 9 | 0x90 | 1 | 0 | 0 | 1 |:| 0 | 0 | 0 | X | 00921 ;-----------|-----------|-------------------|:|-------------------| 00922 ; A | 0x10 | 0 | 0 | 0 | 1 |:| 0 | 0 | 0 | X | 00923 ;-----------|-----------|-------------------|:|-------------------| 00924 ; c | 0x2E | 0 | 0 | 1 | 0 |:| 1 | 1 | 1 | X | MPASM 02.80 Released GLASS.ASM 11-3-2002 21:23:57 PAGE 20 Thermometer, RTD rev 1.0 LOC OBJECT CODE LINE SOURCE TEXT VALUE 00925 ;-----------|-----------|-------------------|:|-------------------| 00926 ; E | 0x22 | 0 | 0 | 1 | 0 |:| 0 | 0 | 1 | X | 00927 ;-----------|-----------|-------------------|:|-------------------| 00928 ; F | 0x32 | 0 | 0 | 1 | 1 |:| 0 | 0 | 1 | X | 00929 ;-----------|-----------|-------------------|:|-------------------| 00930 ; g | 0x80 | 1 | 0 | 0 | 0 |:| 0 | 0 | 0 | X | 00931 ;-----------|-----------|-------------------|:|-------------------| 00932 ; h | 0x16 | 0 | 0 | 0 | 1 |:| 0 | 1 | 1 | X | 00933 ;-----------|-----------|-------------------|:|-------------------| 00934 ; i | 0xDE | 1 | 1 | 0 | 1 |:| 1 | 1 | 1 | X | 00935 ;-----------|-----------|-------------------|:|-------------------| 00936 ; o | 0x0E | 0 | 0 | 0 | 0 |:| 1 | 1 | 1 | X | 00937 ;-----------|-----------|-------------------|:|-------------------| 00938 ; P | 0x30 | 0 | 0 | 1 | 1 |:| 0 | 0 | 0 | X | 00939 ;-----------|-----------|-------------------|:|-------------------| 00940 ; t | 0x36 | 0 | 0 | 1 | 1 |:| 0 | 1 | 1 | X | 00941 ;-----------|-----------|-------------------|:|-------------------| 00942 ; u | 0x4E | 0 | 1 | 0 | 0 |:| 1 | 1 | 1 | X | 00943 ;-----------|-----------|-------------------|:|-------------------| 00944 ; BLANK | 0xFC | 1 | 1 | 1 | 1 |:| 1 | 1 | 1 | X | 00945 ;------------------------------------------------------------------ 00946 ;****************************************************************** 00947 ; DIGIT2 HI NIB DIGIT2 LO NIB 00948 ; IN IN 00949 ; HCOM1A /\ HCOM2A /\ 00950 ;....................... LO NIB / \ LO NIB / \ 00951 ; (XXx8.Xx) . ______/COM2\_____ ______/COM1\_____ 00952 ; 2ND DIGIT & DP . / \ / \ 00953 ;.......................|---------:---------|:|---------:---------| 00954 ; | LCD PIN# | 8 | 9 | 10 | 11 |:| 8 | 9 | 10 | 11 | 00955 ;...........| BIT | B3 | B2 | B1 | B0 |:| B3 | B2 | B1 | B0 | 00956 ; DISPLAY | PIC-I/O | RD3| RD2| RD1| RD0|:| RD3| RD2| RD1| RD0| 00957 ; CHARACTER | SEGMENT | 2e | 2g | 2c | 2d |:| 2f | 2a | 2b | DP | 00958 ;___________|___________|___________________|:|___________________| 00959 ; SAME TABLE AS ABOVE SAME TABLE AS ABOVE SAME TABLE AS ABOVE| 00960 ;------------------------------------------------------------------ 00961 ;****************************************************************** 00962 ; DIGIT3 HI NIB DIGIT3 LO NIB 00963 ; IN IN 00964 ; LCOM1A /\ LCOM2A /\ 00965 ;....................... LO NIB / \ LO NIB / \ 00966 ; (XX:Xx8x) . ______/COM2\_____ ______/COM1\_____ 00967 ; 3RD DIGIT & COLON . / \ / \ 00968 ;.......................|---------:---------|:|---------:---------| 00969 ; | LCD PIN# | 12 | 13 | 14 | 7 |:| 12 | 13 | 14 | 7 | 00970 ;...........| BIT | B3 | B2 | B1 | B0 |:| B3 | B2 | B1 | B0 | 00971 ; DISPLAY | PIC-I/O | RC3| RC2| RC1| RC0|:| RC3| RC2| RC1| RC0| 00972 ; CHARACTER | SEGMENT | 3e | 3g | 3c | 3d |:| 3f | 3a | 3b | col| 00973 ;___________|___________|___________________|:|___________________| 00974 ; SAME TABLE AS ABOVE SAME TABLE AS ABOVE SAME TABLE AS ABOVE| 00975 ;------------------------------------------------------------------ 00976 ;****************************************************************** 00977 ; LCOM1A /\ LCOM2A /\ MPASM 02.80 Released GLASS.ASM 11-3-2002 21:23:57 PAGE 21 Thermometer, RTD rev 1.0 LOC OBJECT CODE LINE SOURCE TEXT VALUE 00978 ;....................... HI NIB / \ HI NIB / \ 00979 ; (XXxXxXF) . ______/COM2\_____ ______/COM1\_____ 00980 ; Degree, C, F Icons . / \ / \ 00981 ;.......................|---------:---------|:|---------:---------| 00982 ; | LCD PIN# | 16 | 15 | |:| 16 | 15 | | 00983 ;...........| BIT | B5 | B4 | |:| B5 | B4 | | 00984 ; DISPLAY | PIC-I/O | RC5| RC4| |:| RC5| RC4| | 00985 ; CHARACTER | SEGMENT | Z2 | | |:| Z1 | Y | | 00986 ;___________|___________|___________________|:|___________________| 00987 ;Degree C | | 1 | X | |:| 0 | 0 | | 00988 ;-------------------------------------------|:|-------------------| 00989 ;Degree F | | 0 | X | |:| 1 | 0 | | 00990 ;------------------------------------------------------------------ 00991 ;****************************************************************** 00992 ;EXAMPLE: PRINTING 195.8 deg C (14 DATA BITS REQUIRED) 00993 ;1 IS K, 9 IS THE 1ST DIGIT, 5 IS THE 2ND DIGIT, 8 IS THE 3RD DIGIT 00994 ;FIND BIT PATTERN FROM TABLE. 00995 ;K, DP, MINUS, DEG, C, F ARE MANUALLY MANAGED. 00996 ; 00997 ;******************************************************************* 00998 ;COM1A THE 1ST BACKPLANE COM1A COM1A THE 1ST BACKPLANE COM1A 00999 ;******************************************************************* 01000 ;COM1A | RD7| RD6| RD5| RD4|| RD3| RD2| RD1| RD0| 01001 ;a) FIND HI NIBBLE FOR 9 01002 ; 9 | 0x90 | 1 | 0 | 0 | 1 |:| 0 | 0 | 0 | X | 01003 ;b) MASK HI NIBBLE | 1 | 0 | 0 | 1 |:| 01004 ; 01005 ;c) FIND HI NIBBLE FOR 5 01006 ; 5 | 0x82 | 1 | 0 | 0 | 0 |:| 0 | 0 | 1 | X | 01007 ;d) MASK HI NIBBLE AND MOVE TO LO NIBBLE POSITION 01008 ; 5 | 0x08 | | | | |:| 1 | 0 | 0 | 0 | 01009 ; 01010 ;e) INCLUSIVE-OR BOTH BYTES 01011 ; 9 5 01012 ; /----1ST DIGIT----\ /----2ND DIGIT----\ 01013 ;COM1A | RD7| RD6| RD5| RD4|:| RD3| RD2| RD1| RD0| 01014 ;RESULT | 0x98 | 1 | 0 | 0 | 1 |:| 1 | 0 | 0 | 0 | 01015 ;............................................................................. 01016 ;NEXT 01017 ;f) FIND HI NIBBLE FOR 8 | RC7| RC6| RC5| RC4|:| RC3| RC2| RC1| RC0| 01018 ; 8 | 0x00 | 0 | 0 | 0 | 0 |:| 0 | 0 | 0 | X | 01019 ;g) MASK HI NIBBLE AND MOVE TO LO NIBBLE POSITION 01020 ; 8 | 0x00 | | | | |:| 0 | 0 | 0 | X | 01021 ;h) DE-ACTIVATE Z2, RC5 (PART OF "C") & DE-ACITVATE MINUS SIGN RC0 01022 ;SET RC0 & RC5 MANUALLY | X | X | 1 | X |:| X | X | X | 1 | 01023 ; ^ ^ 01024 ;i) INCLUSIVE-OR BOTH BYTES 01025 ; Z2 8 01026 ; /----ICONS---\ /----3ND DIGIT----\ 01027 ;COM1A | RC7| RC6| RC5| RC4|:| RC3| RC2| RC1| RC0| 01028 ;RESULT | 0x21 | X | X | 1 | X |:| 0 | 0 | 0 | 1 | 01029 ;............................................................................. 01030 ;............................................................................. MPASM 02.80 Released GLASS.ASM 11-3-2002 21:23:57 PAGE 22 Thermometer, RTD rev 1.0 LOC OBJECT CODE LINE SOURCE TEXT VALUE 01031 ;............................................................................. 01032 ;******************************************************************* 01033 ;COM2A THE 1ST BACKPLANE COM2A COM2A THE 1ST BACKPLANE COM2A 01034 ;******************************************************************* 01035 ;COM2A | RD7| RD6| RD5| RD4|| RD3| RD2| RD1| RD0| 01036 ;j) FIND LO NIBBLE FOR 9 01037 ; 9 | 0x90 | 1 | 0 | 0 | 1 |:| 0 | 0 | 0 | X | 01038 ;k) MASK LO NIBBLE & MOVE IT TO HI NIBBLE 01039 ; | 0 | 0 | 0 | X |:| | | | | 01040 ;l) FIND LO NIBBLE FOR 5 01041 ; 5 | 0x82 | 1 | 0 | 0 | 0 |:| 0 | 0 | 1 | X | 01042 ;m) MASK LO NIBBLE 01043 ; 5 | 0x02 | | | | |:| 0 | 0 | 1 | X | 01044 ; 01045 ;n) INCLUSIVE-OR BOTH BYTES 01046 ; 9 5 01047 ; /----1ST DIGIT----\ /----2ND DIGIT----\ 01048 ;COM2A | RD7| RD6| RD5| RD4|:| RD3| RD2| RD1| RD0| 01049 ;PRE-RESULT | 0x02 | 0 | 0 | 0 | X |:| 0 | 0 | 1 | X | 01050 ; 01051 ;o) ADJUST TO ABOVE RESULT BY SETTING DP AND K STATUS 01052 ; ACTIVATE DP & K 01053 ; DP CLR BIT0 MANUALLY | 0 | 0 | 0 | 0 |:| 0 | 0 | 1 | 0 | 01054 ; K CLR BIT4 MANUALLY ^ ^ 01055 ;FINAL-RESULT | 0x02 01056 ;................................................................... 01057 ;NEXT 01058 ;p) FIND LO NIBBLE FOR 8 | RC7| RC6| RC5| RC4|:| RC3| RC2| RC1| RC0| 01059 ; 8 | 0x00 | 0 | 0 | 0 | 0 |:| 0 | 0 | 0 | X | 01060 ;q) MASK LO NIBBLE 01061 ; 8 | 0x00 | X | X | X | X |:| 0 | 0 | 0 | 0 | 01062 ;LCOM2A 01063 ;PRE-RESULT | 0x00 01064 ;r) ADJUST TO ABOVE RESULT BY SETTING Y AND Z1 01065 ; ACTIVATE Y (Deg SIGN & PART OF "F")-->RC4 -->Y 01066 ; AND ACTIVATE CENTER TAIL OF "F" -->RC5 -->ZI 01067 ;CLR RC4 & RC5 MANUALLY | X | X | 0 | 0 |:| 0 | 0 | 0 | 0 | 01068 ; ^ ^ 01069 ; Z1 8 01070 ; /----ICONS---\ /----3ND DIGIT----\ 01071 ;COM2A | RC7| RC6| RC5| RC4|:| RC3| RC2| RC1| RC0| 01072 ;RESULT | 0x00 | X | X | 0 | 0 |:| 0 | 0 | 0 | 0 | 01073 ;****************************************************************** 01074 ; 01075 ;\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/ 01076 ;///////////////////////////////////////////////////////// 01077 ;********************************************************* 01078 ; SINGLE OUT SIMPLEX COMMUNICATION DATA OUT TID-BITS 01079 ;********************************************************* 01080 ; 01081 ;********************************************************* 01082 ; FEEL FREE TO ASK! TRANSMIT OUT THERMOSTOR VALUES 01083 ;********************************************************* MPASM 02.80 Released GLASS.ASM 11-3-2002 21:23:57 PAGE 23 Thermometer, RTD rev 1.0 LOC OBJECT CODE LINE SOURCE TEXT VALUE 01084 ;SINGLE PIN PROPRIATARY PROTOCOL, TRANSMIT TEMPERATURE 3 DIGIT 01085 ;& DICMAL POINT VALUE, MINUS SIGN AND OTHER STATUS. 01086 ;CHECK TO SEE VIA TIMER IF YOU HAVE ENOUGH TIME 01087 ;TO TRANSMIT THE STREAM (SINGLE PIN TRANSMIT) 01088 ;THIS CHECK IS NOT REQUIRED BUT HAS BEEN ADAPTED TO ENSURE 01089 ;VADILITY OF LOBYTE & HIBYTE & MINUS SIGN 01090 ;********************************************************* 01091 ;IN THE SPREAD SHEET, TEST THE MINUS CELL. IF TRUE ( 1 ) THEN MULTIPLY 01092 ;VALUE BY -1. IF NOT TRUE, THEN DON'T MULTIPLY. 01093 ;********************************************************** 01094 ;CONTROL TO HOST PROTOCOL SB + 34 BITS + PARITY BIT TRAIN 01095 ;MSB = START BIT 01096 ;BYTE 4 B7-B3 = = HOST NETID (0x1A)->11010 B34-B30 01097 ;BYTE 3 B7,B6,B5,B4,B3 = CONTROL NET I.D. B29-B25 01098 ; 01099 ;BYTE 1 B7-B0 = SET POINT B13-B6 01100 ; 01101 ;BYTE 0 B7-B0 = HOST NETID (0x1A) AGAIN B5-B1 01102 ;PARITY BIT B0 01103 01104 ;VERIFICATON IS MADE AGAINS THE STOP BIT, THE PARITY BIT 01105 ;MOVED OR NOT AND THE ANDING OF THE TWO NET I.D. PACKET 01106 ; 01107 ;THE HOST DRIVER WILL HAVE A NET LIST UPDATABLE VIA CONFIGURATION 01108 ; 01109 ;WHEN RETREIVING THE ON BOARD NET I.D. VIA THE A/D, CONVERT IT 01110 ;TO A HEX NUMBER AND SHIFT IT TO THE 5 MSB POSTION 01111 ;FROM B0,B1,B2,B3,B4 01112 ;TO---->B3,B4,B5,B6,B7 WHERE NEW B3 = OLD B0 01113 ; 01114 ;********************************************************* 01115 ;TRANSMITTING (TEMPERATURE * 100) VALUE, TO HOST, 01116 ;SB + 16 DATA BITS + 11 TIMING/ID BITS FR CTRL TO HOST = 27 BIT STREAM 01117 ;BYTES TRANSMITTED PER SECOND = _______ TEMPERATURE = 12 BIT 01118 ;NOTE THAT THIS VALUE IS MULTIPLIED BY 100.0 01119 ;TO DERIVE ACTUAL READING DIVIDE (HIBYTE LOBYTE) BY 100.0 01120 ;IN THE SPREAD SHEET, IF THE SECOND BYTE = 0x01 THEN MULTIPLY 01121 ;RESULT BY -1.0 01122 ;********************************************************* 01123 ;1st BYTE OUT = B34-B30 = HOST NETID (0x1A) ->1 1 0 1 0 01124 ;2ND BYTE OUT = B29-B22 IS FOR MINUS SIGN = 0x01 01125 ;3RD BYTE OUT = B21-B14 = HIBYTE REGISTER ->B8-B15 01126 ;4TH BYTE OUT = B13-B6 = LOBYTE REGISTER ->B7-B0 01127 ;5th BYTE OUT = B5-B1 = HOST NETID (0x1A) ->1 1 0 1 0 01128 ;LAST BIT OUT = B0 = PARITY = DERRIVED WHILE TRANSMITTING 01129 ;EVEN PARITY. IF EVEN # OF ONES SEND OUT HI PARITY BIT 01130 ;EVEN PARITY. IF UN- EVEN # OF ONES SEND OUT LO PARITY BIT 01131 ;********************************************************* 01132 ; SEEMS TO BE 8 INSTRUCTION PER BIT 01133 ; 234 567 01134 ; BEFORE CALL : 012 345 678 901 234 567 890 01135 ; 01 123 : 456 789 111 111 111 122 222 222 223 01136 ; 8 SYNC BITS I.E. 01..CALL TO HERE... 1xx : 1xx 1xx 1xx 0xx 1xx 1xx 1xx 0xx 0xx MPASM 02.80 Released GLASS.ASM 11-3-2002 21:23:57 PAGE 24 Thermometer, RTD rev 1.0 LOC OBJECT CODE LINE SOURCE TEXT VALUE 01137 ; \__________/ \_________________/ 01138 ; 0x1A XXX1 1010 9.0 SYNC BITS HOST I.D. 01139 ;******************************************************************* 01140 ;6 instruction per bit 01141 ;5th BYTE OUT = B5-B1 = HOST NETID (0x1A) ->1 1 0 1 0 01142 ; BITa BITb BITc BITd BITe 01143 ;CONTROL I.D. CODE SET AT 0x02 01144 ;THREE BIT TIME TIMING, NEXT THREE BIT TIME = DATA BIT, REPEAT 01145 ;AFTER THE START BIT THE RECEIVER TAKE 8 BIT TIME FOR LOOK FOR THE 1ST 01146 ;DATA BIT WHICH IS DONE WITHIN THE INTERRUPT. 01147 ;18 LINES 01148 ;******************************************************************* 01149 ; 01150 ; 01151 ; ORG 0x0XXX ;TYPICALLY HAVE THESE IN HIGH PAGE 01152 ;********************************************************* 01153 ;ROUTINE WHICH OFFERS STATUS ON BOTH 16 BIT #' IN ACCa & ACCb 01154 ;NMFLAG INCLUDES ZERO, EQUAL, BIGGER & LESS THAN STATUS' 01155 ;ACCa & ACCb ARE RETURNED WITH THE SAME VALUE AS BEFORE 01156 ;SUB-ROUTINE RUN. TRY NOT TO PUT CALL WITHIN LONG CALLS 01157 ; 01158 ;THIS IS A MUST HAVE ROUTINE FOR EVERYBODY. NOT INCLUDED IN THIS DEMO 01159 ;********************************************************* 016C 3010 01160 NUMTST MOVLW 0x10 016D 00AA 01161 MOVWF TEMP1 Message[305]: Using default destination of 1 (file). 016E 0BAA 01162 NUMLP DECFSZ TEMP1 ;REPLACED IT WITH THIS DELAY FOR THIS DEMO! 016F 296E 01163 GOTO NUMLP 0170 0008 01164 RETURN 01165 ;********************************************************* 01166 ;\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\ 01167 ;///////////////////////////////////////////////////////// 01168 ;********************************************************* 01169 ; CONFIGURE I/O PORTS 01170 ;********************************************************* 01171 ; ORG 0x0XXX ;WAS 0E3C DIFF = 1A OR 26 01172 DOIOS BANK1 ;A/D PORT CFG PG74 OR PG10-111 0171 1683 M BSF STATUS,5 ;SET REGISTER BANK 1 0172 3006 01173 MOVLW 0x06 ;RA0,RA1,RA2,RA3,RA4,RA5 Message[302]: Register in operand not in bank 0. Ensure that bank bits are correct. 0173 009F 01174 MOVWF ADCON1 ;D D D D D D 01175 BANK0 0174 1283 M BCF STATUS,5 ;SET REGISTER BANK 0 01176 ;COMEs UP FAST ENOUGH & PIC SEES,IT AS LOW BAT 0175 1105 01177 BCF PORTA,2 ;ENABLE ANALOG POWER SUPPLY 0176 1231 01178 BCF DEGCF,4 ;NO MORE SLEEP 0177 0186 01179 CLRF PORTB 01180 ; CLRF PORTC 01181 ; CLRF PORTD 01182 ; CLRF PORTE 01183 BANK1 0178 1683 M BSF STATUS,5 ;SET REGISTER BANK 1 0179 3019 01184 MOVLW 0x19 ;PG 10-44, PG 74 MPASM 02.80 Released GLASS.ASM 11-3-2002 21:23:57 PAGE 25 Thermometer, RTD rev 1.0 LOC OBJECT CODE LINE SOURCE TEXT VALUE Message[302]: Register in operand not in bank 0. Ensure that bank bits are correct. 017A 0085 01185 MOVWF TRISA ;A/D0, A/D1, RA2, A/D3, RA4, RA5 017B 3005 01186 MOVLW 0x05 ; Message[302]: Register in operand not in bank 0. Ensure that bank bits are correct. 017C 0086 01187 MOVWF TRISB ;0000 010 1(EXT INT) 017D 30C0 01188 MOVLW 0xC0 ;1011 1111 RC7=RX,RC6=TX/STIR,RC5=1 Message[302]: Register in operand not in bank 0. Ensure that bank bits are correct. 017E 0087 01189 MOVWF TRISC ;RC4=1,RC3=1,RC2=1,RC1=1,RC0=1 Message[302]: Register in operand not in bank 0. Ensure that bank bits are correct. 017F 0188 01190 CLRF TRISD ;0000 0000 01191 ; CLRF TRISE ;RE0-RE2=INPUT, DEFAULT 01192 ; BANK0 ;PRESET PORTE UNACTIVATED I/O's 01193 ;********************************************************* 01194 ; SET POWER ON RESET FLAGS 01195 ;********************************************************* 01196 ;NOTICE DIFF WITH 74A IN PCON, BROWN-OUT VERSUS POWER-ON RESET 01197 ; BANK1 0180 3003 01198 MOVLW 0x03 ; CAPTURE2\COMPARE2\PWM2 Message[302]: Register in operand not in bank 0. Ensure that bank bits are correct. 0181 008E 01199 MOVWF PCON ;RESET POWERON FLAG PG18 01200 ;********************************************************* 01201 ; DIABLE ALL INTERRUPTS 01202 ;********************************************************* 01203 ; CLRF PIE1 01204 ; BCF INTCON,5 ;DISABLE TMR0 INT (DONE ALREADY) 01205 ; BANK0 01206 ; BCF PIR2,0 ;CLEAR CCP2IF FLAG 01207 ;********************************************************* 01208 ; CONFIGURE TIMER0 ;;PRESCALER --> WATCH-DOG 01209 ;********************************************************* 0182 30C7 01210 MOVLW 0xC7 ;RISING EDGE TRIGGER RB0 EXT INT, NO WDT Message[302]: Register in operand not in bank 0. Ensure that bank bits are correct. 0183 0081 01211 MOVWF OPTN ;INT OPTIONS OPTION REG PG13 01212 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; 01213 ;;;;;;;;;;;;;;;;;SETTING THE GLASS' DUTY CYCLE;;;;;;;;;;;; 01214 ;SEE CONFIGURE TIMER 2 NOTE BELOW 01215 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; 01216 ;;;;; MOVLW 0x12 ;MAX = 22, MIN =04, 0184 301D 01217 MOVLW 0x1D ;0x1D = 7.680ms PER CYCLE, 33Hz REFRESH Message[302]: Register in operand not in bank 0. Ensure that bank bits are correct. 0185 0092 01218 MOVWF PR2 ; Message[302]: Register in operand not in bank 0. Ensure that bank bits are correct. 0186 148C 01219 BSF PIE1,1 ;ENABLE TIMER 2 INT Message[302]: Register in operand not in bank 0. Ensure that bank bits are correct. 0187 140C 01220 BSF PIE1,0 ;ENABLE TIMER 1 INT 01221 BANK0 0188 1283 M BCF STATUS,5 ;SET REGISTER BANK 0 01222 ; CLRF TMR0 ;CLEAR TIMER 0 01223 ;********************************************************* 01224 ; CONFIGURE TIMER1 PRESCALER = MAX = 8 01225 ;********************************************************* 01226 ;TIMER1 IS A 16 BIT TIMER (TMR1H,TMR1L) WITH INTERRUPT 01227 ;STATUS @ PIR1,1. IT CAN BE TURNED OFF BY T1CON,0=LO MPASM 02.80 Released GLASS.ASM 11-3-2002 21:23:57 PAGE 26 Thermometer, RTD rev 1.0 LOC OBJECT CODE LINE SOURCE TEXT VALUE 01228 ;PRESCALE = 8 * 1us * 65536 = 524.288ms 01229 ;TIMER1 IS NOT ACTIVATED YET 01230 ;********************************************************* 0189 3035 01231 MOVLW 0x35 ; 00 11 0 1 0 1 PG36 018A 0090 01232 MOVWF T1CON ;TIMER1 PRESCALE = 8 01233 ;********************************************************* 01234 ; CONFIGURE TIMER2 ;PRESCALE=16, POSTSCALE=16 01235 ;********************************************************* 01236 ;TIMER2 IS A 8 BIT TIMER (TMR2) WITH INTERRUPT 01237 ;STATUS @ PIR1,0. IT CAN BE TURNED OFF BY T1CON,0=LO 01238 ;PRESCALE = 16, POSTSCALE =16 (65.536ms MAX) @ 4MHz CRYSTAL 01239 ;OSC/4 = 4MHz/4 = 1MHz ...1us INCREMENT 01240 ;TMR2 COUNTS UP UNTIL IT REACHES VALUE IN PR2, THEN IT RESETS TO 0. 01241 ;I.E. TMR2 = PRESCALE * POSTSCAL * PR2 * 1us 01242 ;I.E. TMR2 / PRESCALE * POSTSCAL = PR2 01243 ; 01244 ; 01245 ; if.........if WE WERE USING 50Hz DC THEN 20ms WOULD INCLUDE 01246 ;REFRESHING 4 CYCLES (MODES) OR THE COMPLETE GLASS AT 5ms A CYCLE. 01247 ; 01248 ;50Hz OR 20ms FOR DC OR 5ms REFRESH TIME PER SEGMENT COMPLEMENT (MODE). 01249 ;I.E. (20ms / 256 / 1us = 78.125 FOR FOUR FOUR CYCLE LENGHTS 01250 ;78.125 / 4 CYCLES = 19.53 OR (18 + 1) 01251 ;I.E. (5ms / 256 / 1us = 19.53 FOR APPROXIMATE PR2 VALUE FOR ONE CYCLE 01252 ;I.E. 19 * 256 * 1us = 4.864ms 01253 ;SO FOR THIS DC RATE 1 + 18.0 = 0x12 FOR PR2 VALUE FOR A REFRESH RATE OF 51Hz. 01254 ;COULD ALSO BE, 1 + 19.0 * 256 * 1us = 5.12ms 01255 ;YOU CAN FINE TUNE THIS IF YOU REALLY WANT TO IN THE INTERRUPT ROUTINE, BUT 01256 ;FINE TUNING IN MY OPINION IS NOT REQUIRED. CONSIDER THE GLASS' PERSISTENCE. 01257 ;DIFFERENT MANUFACTURE, DIFFERENT PERSISTENCE & THRESHOLD LEVELS! 01258 ;DON'T FORGET YOU MAY HAVE SOMETHING WHICH REQUIRES TIME TO DO BETWEEN 01259 ;REFRESH CYCLES, LIKE DIGITAL FILTERING YOUR A/D, SO FASTER IS NOT 01260 ;ALWAYS BETTER. TOO FAST REFRESH WILL CAUSE SHADOWING (GHOSTING), TOO LOW WILL 01261 ;CAUSE FLICKERING. CHECK VOLTAGE dc TO ASSURE NULL OR MINIMUM VALUE. 01262 ;SURE MAKES IT NICE WHEN DUTY CYCLE IS PROGRAMMABLE LIKE WITH THESE PICs. 01263 ; 01264 ;THIS SPECIFIC DESIGN INCLUDES A 3.8VDC SUPPLY TO THE 16c74A. 01265 ;MY PR2 IS 0x1D, 29.0. OR 30 PERIODS. MY REFRESH RATE IS ABOUT 32Hz. NOTE AGAIN THAT 01266 ;THE LAST DECIMAL POINT'S DATA SHOULD ONLY BE UPDATED TWICE A SECOND 01267 ;OR ELSE IT WILL FLICKER DUE TO DATA UPDATES. 01268 ;(1.0 + 29.0) * 256 * 1us = 7.680ms, THEN ABOUT 40 INSTRUCTION IN INTERRUPT ROUTINE 01269 ;4 * 7.680ms = 30.720ms OR 32Hz (LESS POWER REQUIREMENT AT LOWER FREQUENCIES) 01270 ;IF YOU'VE GOTTEN TO THIS POINT, YOU MUST BE HAVING FUN. 01271 ;********************************************************* 018B 30FF 01272 MOVLW 0xFF ; 0 1111 1 11 PG2-575, PG40 018C 0092 01273 MOVWF T2CON ;TIMER2 PRESCALE = 16, POSTSCALER = 16 018D 01274 PRERUN 01275 ; BSF DSPLAY,6 ;SET = ALL DIGIT WERE COMPLETLY PRINTED 018D 216C 01276 WAIST CALL NUMTST ;WASTE ANOTHER 100us TIME Message[305]: Using default destination of 1 (file). 018E 0BBF 01277 DECFSZ BCDTMP ;WAIST ABOUT 12ms 018F 298D 01278 GOTO WAIST 0190 01AA 01279 CLRF TEMP1 MPASM 02.80 Released GLASS.ASM 11-3-2002 21:23:57 PAGE 27 Thermometer, RTD rev 1.0 LOC OBJECT CODE LINE SOURCE TEXT VALUE 0191 30D0 01280 MOVLW 0xD0 ;EXT INT, PERIPHERAL INT, GLOBAL INT 0192 008B 01281 MOVWF INTCON 0193 0008 01282 RETURN 01283 ; 01284 ; 01285 ; 01286 END MPASM 02.80 Released GLASS.ASM 11-3-2002 21:23:57 PAGE 28 Thermometer, RTD rev 1.0 SYMBOL TABLE LABEL VALUE ADCON0 0000001F ADCON1 0000009F ADJBCD 000000DF ADRES 0000001E BANK0 BANK1 BATCNT 0000002B BATEST 0000009E BATOK 0000009E BCD 000000CE BCDLP 000000D4 BCDTMP 0000003F BIDSPL 00000144 BYDSPL 00000137 BYELCD 0000005E BYOUT 00000166 C 00000000 CCP1CON 00000017 CCP2CON 0000001D CCPR1H 00000016 CCPR1L 00000015 CCPR2H 0000001C CCPR2L 0000001B CR 0000000D D1IS0 00000111 DCIML0 0000003A DCIML1 0000003B DCIML2 0000003C DCML0 0000002C DCML1 0000002D DCML2 0000002E DCMTMP 0000002F DEGCF 00000031 DELAY 00000096 DIG1ME 00000103 DIG2ME 00000112 DIG3ME 00000120 DIGITS 00000038 DIGTHI 00000024 DIGTLO 00000025 DOIOS 00000171 DSPLAY 00000032 ENDBCD 000000F1 FFYNG 00000136 FME 000000C9 FORCME 00000132 FREE26 00000026 FREE27 00000027 FREE28 00000028 FREE29 00000029 FREE40 00000040 FREE41 00000041 FREE42 00000042 MPASM 02.80 Released GLASS.ASM 11-3-2002 21:23:57 PAGE 29 Thermometer, RTD rev 1.0 SYMBOL TABLE LABEL VALUE FREE43 00000043 FREE44 00000044 FREE45 00000045 FREE46 00000046 FREE47 00000047 FREE48 00000048 FREE49 00000049 FREE4A 0000004A FREE4B 0000004B FREE4C 0000004C FREE4D 0000004D FREE4E 0000004E FREE4F 0000004F FREE50 00000050 FREE51 00000051 FREE52 00000052 FREE53 00000053 FREE54 00000054 FREE55 00000055 FREE56 00000056 FREE57 00000057 FREE58 00000058 FREE59 00000059 FREE5A 0000005A FREE5B 0000005B FREE60 00000060 FREE61 00000061 FREE62 00000062 FREE63 00000063 FREE64 00000064 FREE65 00000065 FREE66 00000066 FREE67 00000067 FREE68 00000068 FREE69 00000069 FREE6A 0000006A FREE6B 0000006B FREE6C 0000006C FREE6D 0000006D FREE6E 0000006E FREE6F 0000006F FREE70 00000070 FREE71 00000071 FREE72 00000072 FREE73 00000073 FREE74 00000074 FREE75 00000075 FREE76 00000076 FREE77 00000077 FREE78 00000078 FREE79 00000079 FREE7A 0000007A FREE7B 0000007B MPASM 02.80 Released GLASS.ASM 11-3-2002 21:23:57 PAGE 30 Thermometer, RTD rev 1.0 SYMBOL TABLE LABEL VALUE FREE7C 0000007C FREE7D 0000007D FREE7E 0000007E FREE7F 0000007F FREEA0 000000A0 FREEA1 000000A1 FREEA2 000000A2 FREEA3 000000A3 FREEA4 000000A4 FREEA5 000000A5 FREEA6 000000A6 FREEA7 000000A7 FREEA8 000000A8 FREEA9 000000A9 FREEAA 000000AA FREEAB 000000AB FREEAC 000000AC FREEAD 000000AD FREEAE 000000AE FREEAF 000000AF FREEB0 000000B0 FREEB1 000000B1 FREEB2 000000B2 FREEB3 000000B3 FREEB4 000000B4 FREEB5 000000B5 FREEB6 000000B6 FREEB7 000000B7 FREEB8 000000B8 FREEB9 000000B9 FREEBA 000000BA FREEBB 000000BB FREEBC 000000BC FREEBD 000000BD FREEBE 000000BE FREEBF 000000BF FREEC0 000000C0 FREEC1 000000C1 FREEC2 000000C2 FREEC3 000000C3 FREEC4 000000C4 FREEC5 000000C5 FREEC6 000000C6 FREEC7 000000C7 FREEC8 000000C8 FREEC9 000000C9 FREECA 000000CA FREECB 000000CB FREECC 000000CC FREECD 000000CD FREECE 000000CE FREECF 000000CF FREED0 000000D0 MPASM 02.80 Released GLASS.ASM 11-3-2002 21:23:57 PAGE 31 Thermometer, RTD rev 1.0 SYMBOL TABLE LABEL VALUE FREED1 000000D1 FREED2 000000D2 FREED3 000000D3 FREED4 000000D4 FREED5 000000D5 FREED6 000000D6 FREED7 000000D7 FREED8 000000D8 FREED9 000000D9 FREEDA 000000DA FREEDB 000000DB FREEDC 000000DC FREEDD 000000DD FREEE0 000000E0 FREEE1 000000E1 FREEE2 000000E2 FREEE3 000000E3 FREEE4 000000E4 FREEE5 000000E5 FREEE6 000000E6 FREEE7 000000E7 FREEE8 000000E8 FREEE9 000000E9 FREEEA 000000EA FREEEB 000000EB FREEEC 000000EC FREEED 000000ED FREEEE 000000EE FREEEF 000000EF FREEF0 000000F0 FREEF1 000000F1 FREEF2 000000F2 FREEF3 000000F3 FREEF4 000000F4 FREEF5 000000F5 FREEF6 000000F6 FREEF7 000000F7 FREEF8 000000F8 FREEF9 000000F9 FREEFA 000000FA FREEFB 000000FB FREEFC 000000FC FREEFD 000000FD FREEFE 000000FE FREEFF 000000FF FSR 00000004 GETOFF 000000C3 HBYTE 0000003D HCOM1A 00000034 HCOM2A 00000036 HIBYTE 00000020 INDF 00000000 INTCON 0000000B MPASM 02.80 Released GLASS.ASM 11-3-2002 21:23:57 PAGE 32 Thermometer, RTD rev 1.0 SYMBOL TABLE LABEL VALUE INTVEC 00000004 IPCLAT 0000005D ISTAT 0000005E ISTATH 000000DE IWREG 0000005F IWREGH 000000DF KME 00000129 KTHER 0000010C LBYTE 0000003E LCDMAP 000000A5 LCDTMP 00000030 LCOM1A 00000035 LCOM2A 00000037 LEADG0 00000033 LOBYTE 00000021 MODE1A 00000048 MODE1B 00000062 MODE2A 00000052 MODE2B 00000037 MORBCD 000000DD NETID 00000023 NIGHT 0000002B NOICON 00000168 NUMLP 0000016E NUMTST 0000016C NXINT 00000015 OPTN 00000081 OUTING 000000C1 PAAGE0 PARITY 00000022 PCL 00000002 PCLATH 0000000A PCON 0000008E PIE1 0000008C PIE2 0000008D PIR1 0000000C PIR2 0000000D POPPER 00000021 PORTA 00000005 PORTB 00000006 PORTC 00000007 PORTD 00000008 PORTE 00000009 PR2 00000092 PRERUN 0000018D PUSH RCREG 0000001A RCSTA 00000018 RDA2D 000000CA RNGOUT 00000154 RSTVEC 00000000 RUN 0000007F SIGNME 0000012F MPASM 02.80 Released GLASS.ASM 11-3-2002 21:23:57 PAGE 33 Thermometer, RTD rev 1.0 SYMBOL TABLE LABEL VALUE SLOW 0000005C SP 00000020 SPBRG 00000099 SSPADD 00000093 SSPBUF 00000013 SSPCON 00000014 SSPSTAT 00000094 START 00000071 STATUS 00000003 T1CON 00000010 T2CON 00000012 TEMP1 0000002A TIMMR2 00000031 TMR0 00000001 TMR1H 0000000F TMR1L 0000000E TMR2 00000011 TOGGLE 000000C5 TRISA 00000085 TRISB 00000086 TRISC 00000087 TRISD 00000088 TRISE 00000089 TTYTYM 00000017 TXREG 00000019 TXSTA 00000098 TYMEOK 000000F3 UTILX 0000005B UUTING 000000BD WAIST 0000018D WEIST 00000099 WHYEME 00000131 WREG0 00000039 Z 00000002 __16C74 00000001 MEMORY USAGE MAP ('X' = Used, '-' = Unused) 0000 : XX--XXXXXXXXXXXX XXXXXXXXXXXXXXXX XXXXXXXXXXXXXXXX XXXXXXXXXXXXXXXX 0040 : XXXXXXXXXXXXXXXX XXXXXXXXXXXXXXXX XXXXXXXXXXXXXXXX XXXXXXXXXXXXXXXX 0080 : XXXXXXXXXXXXXXXX XXXXXXXXXXXXXXXX XXXXXXXXXXXXXXXX XXXXXXXXXXXXXXXX 00C0 : XXXXXXXXXXXXXXXX XXXXXXXXXXXXXXXX XXXXXXXXXXXXXXXX XXXXXXXXXXXXXXXX 0100 : XXXXXXXXXXXXXXXX XXXXXXXXXXXXXXXX XXXXXXXXXXXXXXXX XXXXXXXXXXXXXXXX 0140 : XXXXXXXXXXXXXXXX XXXXXXXXXXXXXXXX XXXXXXXXXXXXXXXX XXXXXXXXXXXXXXXX 0180 : XXXXXXXXXXXXXXXX XXXX------------ ---------------- ---------------- All other memory blocks unused. Program Memory Words Used: 402 Program Memory Words Free: 3694 MPASM 02.80 Released GLASS.ASM 11-3-2002 21:23:57 PAGE 34 Thermometer, RTD rev 1.0 Errors : 0 Warnings : 0 reported, 0 suppressed Messages : 51 reported, 0 suppressed