; Full Version for 87C51FA 8K MICro from -67 to 257 degrees F.
;
; ASSEMBLED WITH METALINKS ASM51.EXE
;
; Project: ( Thermostat ), And DS1620 Chip Programmer.
; SOFtware For Control & Use of DS1620
; Digital Thermometer & Thermostat I.C
; Microcontroller ( P87C51FA DIP )
; 11.0592 MHz Crystal
; LCD = { 20 X 4 }
; Port connections as follows.
; Copyright (C) 1998 B. Reynolds EleCTRonics
;
; Micro PIN# TO LCD Pin# Micro Pin# TO DS1620 Pin# LCD Pin#
; p1.0 #1 ----> db0 #7 p3.0 #10 ----> DQ #1 GND #1
; p1.1 #2 ----> db1 #8 p3.1 #11 ----> CLK/CONV #2 VCC #2
; p1.2 #3 ----> db2 #9 p3.2 #12 ----> RST #3 VR #3
; p1.3 #4 ----> db3 #10 p3.3 #13 -------------------> RS #4
; p1.4 #5 ----> db4 #11 p3.4 #14 -------------------> R/W #5
; p1.5 #6 ----> db5 #12 p3.5 #15 -------------------> E #6
; p1.6 #7 ----> db6 #13 DS1620 PIN#
; p1.7 #8 ----> db7 #14 GND #4
; VCC #8
; **********************************************************************
; * User Data Entry Buttons As Follows *
; * *
; * p2.0 = Up : increment temperature setting + display. *
; * p2.1 = Down : decrement temperature setting + display. *
; * p2.2 = Enter : Enter key accepts entry goes to next function.*
; * p2.3 = Stand Alone : Sets DS1620 up for stand alone thermostat *
; * ; operation. *
; * p2.4 = Display : Display high & low 1620 programmed settings. *
; * p2.5 = Mode : Change from ( program ) mode to ( display ) *
; * ; mode. *
; * p2.5 is a slide switch, All others are N.O. Momentary Contact. *
; * *
; **********************************************************************
;
;
;
; Setup Equates Table Here, Inform Assembler of Constants
lcd_data equ 090h
config equ 38h
entrymode equ 6
offcur equ 0ch
linecur equ 0eh
homecur equ 02h
clrDSP equ 01h
offdsp equ 0ah
ondsp equ 0eh
sbuf equ 99h
ren equ 9ch
ri equ 98h
ti equ 99h
lcd_rs equ 0b3h
lcd_rw equ 0b4h
lcd_e equ 0b5h
th_lsb data 30h
th_msb data 31h
tl_lsb data 32h
tl_msb data 33h
b equ 0f0h
p2 equ 0a0h
p3 equ 0b0h
acc equ 0e0h
dph equ 83h
dpl equ 82h
org 0 ; Establish Reset Vector Here
Hello:
lcall resetlcd
lcall initlcd
bsp; mov a,#1
mov b,#0
lcall placecur
lcall prtlcd
db ' --** DS1620 **-- ',0
mov r4,#offcur
lcall wrlcdcom
mov a,#2
mov b,#0
lcall placecur
lcall prtlcd
db ' PROGRAMMER ',0
mov r4,#offcur
lcall wrlcdcom
mov a,#3
mov b,#0
lcall placecur
lcall prtlcd
db ' ',0
mov a,#4
mov b,#0
lcall placecur
lcall prtlcd
db ' { VERSION 1.0 } ',0
lcall big_delay2
lcall big_delay2
comin_back:
lcall resetlcd
lcall initlcd
sjmp select
back:
mov a,#2
mov b,#0
lcall placecur
lcall prtlcd
db '*-{ PROGRAM MODE }-*',0
mov a,#3
mov b,#0
lcall placecur
lcall prtlcd
db ' PRESS FUNCTION KEY ',0
mov r4,#offcur
lcall wrlcdcom
select:
mov p2,#0ffh ; setup port2 for input/ for 8031
; use port0
; isr routine for CPU operation
buttons:
jnb p2.4,isr ; Display 1620 programmed high
; & low setpoints.
jnb p2.5,begin1; MODE SWITCH program/display temp.
jnb p2.2,set1 ; Begin programming sequence for
; DS1620 chip.
jnb p2.3,strt_conv ; issue start_convert for
; stand_alone operation
jb p2.5,back ; Program Mode ?
sjmp buttons ; no key press ? then stay here.
set1:
jnb p2.2,set1 ; debounce keypress
lcall big_delay ;
ljmp up1 ; goto chip programming routine.
begin1:
ljmp begin ; goto display temp routine.
isr:
lcall isr2 ; goto fetch setpoints for
; viewing routine.
sjmp comin_back
strt_conv:
lcall big_delay ; routine to setup 1620 for
; stand-alone ops.
clr p3.2 ;
setb p3.0
setb p3.1
mov a,#0ch
lcall out_cmd
mov a,#00h
lcall out_data
mov a,#0eeh
lcall out_cmd
lcall big_delay
clr p3.2
lcall resetlcd
lcall initlcd
lcall prtlcd
db ' DS1620 PROGRAMMED ',0
mov a,#2nbsp; mov b,#0
lcall placecur
lcall prtlcd
db 'FOR STAND ALONE OPS',0
mov a,#3
mov b,#0
lcall placecur
lcall prtlcd
db 'POWER OFF PROGRAMMER',0
mov a,#4
mov b,#0
lcall placecur
lcall prtlcd
db 'AND REMOVE 1620 I.C.',0
mov r4,#offcur
lcall wrlcdcom
alone_only:
sjmp alone_only ; loop here for user to power
; down device and remove 1620 I.C.
; from programmer.
Begin:
lcall resetlcd ; begin routine for display of
; temperature
lcall initlcd ; with 1620 device LOCated in
; programmer.
; We start here if the MODE
; switch is in display position
mov a,#1
mov b,#0
lcall placecur
lcall prtlcd ; Print some fancy corners
db '* *',0
mov a,#4
mov b,#0
lcall placecur
lcall prtlcd
db '* *',0
mov a,#2
mov b,#0
lcall placecur
lcall prtlcd
db ' DS1620 TEMPERATURE ',0
mov a,#3 ; set cursor on line #3
mov b,#12 ; at position #12
lcall placecur ; place cursor routine
lcall prtlcd ; print routine
db 11011111b,01000110b,0
; Data for deg F symbol.
mov a,#0ffh
lcall delay
mov a,#3 ; Set location for cursor
mov b,#6 ; to display current
; temperature.
lcall placecur
mov r4,#offcur ; Turn OFF Cursor.
lcall wrlcdcom ; write lcd command routine
; Here we will continously convert temp,
; in CPU Mode for Temp Display
check_tmp:
clr p3.2 ; reset ds1620
setb p3.0 ; RXD and TXD high
setb p3.1
mov a,#0ch ; Load Write configuration
; byte instruction
lcall out_cmd ; send it to 1620
mov a,#02h ; set config byte = cpu mode,
lcall out_data ; send it to 1620
mov a,#0eeh ; initiate temperature conversion
lcall out_cmd
mov a,#0ffh ; set delay time here
lcall delay
read_tmp:
clr a
mov a,#0aah ; Load instruction to fetch last temp
lcall out_cmd ; conversion result.
nbsp; lcall in_data ; get temp data from ds1620 ( LSB )
mov r3,a ; move ( LSB ) of temp data to Storage
; Register.
lcall in_data ; get temp data from ds1620 ( MSB )
mov r1,a ; move ( MSB ) of temp data to Storage
; Register.
; use data retrieved into Storage Registers, to point to
; lookup_table data to be shown on LCD.
mov a,r3 ; mov conversion results to ACC
lcall look_up ; Fetch display data.
mov a,#3 ; select lcd line #2.
mov b,#6 ; start at location #7 with
; temp display.
lcall placecur ; place cursor at above selected
; location.
mov r4,#offcur ; kill the cursor so we dont
; have a cursor
lcall wrlcdcom ; being displayed.
lcall delay ; Delay between fetch.
jb p2.5,comin_back1
ljmp read_tmp ; if done, go get another reading.
comin_back1:
ljmp comin_back; Goto program mode if switch selected
look_up:
cjne r1,#01h,over_32
;determine if temp is above 32.
sjmp b0
over_32:
ljmp x0
st:
ret ; return to calling routine from here.
; Incredibly ( BIG ) Look-Up table begins here...........
b0: cjne a,#92h,b1 ; below 32 look up table
lcall prtlcd ; -67 Deg F Lowest Value.
db '-67.0',0
ljmp st
b1: cjne a,#93h,b2
lcall prtlcd
db '-66.1',0
ljmp st
b2: cjne a,#94h,b3
lcall prtlcd
db '-65.2',0
ljmp st
b3: cjne a,#95h,b4
lcall prtlcd
db '-64.3',0
ljmp st
b4: cjne a,#96h,b5
lcall prtlcd
db '-63.4',0
ljmp st
b5: cjne a,#97h,b6
lcall prtlcd
db '-62.5',0
ljmp st
b6: cjne a,#98h,b7
lcall prtlcd
db '-61.6',0
ljmp st
b7: cjne a,#99h,b8
lcall prtlcd
db '-60.7',0
ljmp st
b8: cjne a,#9ah,b9
lcall prtlcd
db '-59.8',0
ljmp st
b9: cjne a,#9bh,b10
lcall prtlcd
db '-58.9',0
ljmp st
b10: cjne a,#9ch,b11
lcall prtlcd
db '-58.0',0
ljmp&nbs
上一篇:89c51控制的16*16LED点阵显示
下一篇:LCD12864汇编语言程序例子
设计资源 培训 开发板 精华推荐
- 首都医科大学王长明:针对癫痫的数字疗法已进入使用阶段
- 非常见问题解答第223期:如何在没有软启动方程的情况下测量和确定软启动时序?
- 兆易创新GD25/55全系列车规级SPI NOR Flash荣获ISO 26262 ASIL D功能安全认证证书
- 新型IsoVu™ 隔离电流探头:为电流测量带来全新维度
- 英飞凌推出简化电机控制开发的ModusToolbox™电机套件
- 意法半导体IO-Link执行器电路板为工业监控和设备厂商带来一站式参考设计
- Melexis采用无磁芯技术缩小电流感测装置尺寸
- 千丘智能侍淳博:用数字疗法,点亮“孤独症”儿童的光
- 数药智能冯尚:ADHD数字疗法正为儿童“多动症”提供更有效便捷服务
- Vicor高性能电源模块助力低空航空电子设备和 EVTOL的发展