本帖最后由 mirochain1980 于 2011-7-13 12:49 编辑
我用万用板做了一个简单的AT89S51和MAX232构成的与PC实现RS232通信的实验电路,电源用电脑USB口供电,晶振用12MHZ,波特率设置为2400,程序成功下载到单片机,用三根单芯线和一个串口母头的2、3、5脚与MAX232的7、8脚,地线相连后和电脑串口连接,程序是循环向SBUF发送08H,A6H;用串口调试助手观察。
结果:
万用表量AT89S51P3.0/TXD和P3.1/RXD电压4.7V,MAX232各引脚电压值都正常
AT89S51的悬空引脚用万用表量电压都是4.7V
串口调试助手勾选16进制显示,窗口未显示任何东西
注:检查线路应该没有什么问题,程序肯定下载到单片机了,查FLASH可以看到,这么简单的程序请大家相信俺,大家帮帮忙啊,现在做一个18B20的电脑显示温度传感模块实验,第一步就遇到问题了,温度采集及通过RS232发送至PC程序贴在5楼,帮忙啊帮忙!!
友情提示: 此问题已得到解决,问题已经关闭,关闭后问题禁止继续编辑,回答。
我用两个DS18B20,单独供电(非寄生供电接线),单总线分别接P1.0、P1.1(分别控制两个温度传感器) tempvalue_1 equ 30h
tempvalue_2 equ 31h
flag bit 00h
regedit_com:
mov scon,#50h
mov tmod,#20h
mov th1,#0f3h
mov tl1,#0f3h
setb tr1
start:
org 00h
collect_t1: init_18201:
setb p1.0
nop
clr p1.0
mov r0,#06bh
tsr11:
djnz r0,tsr11
setb p1.0
mov r0,#25h
tsr12:
jnb p1.0,tsr13
djnz r0,tsr12
jmp tsr14
tsr13:
setb flag
jmp tsr15
tsr14:
clr flag
jmp tsr17
tsr15:
mov r0,06bh
tsr16:
djnz r0,tsr16
tsr17:
setb p1.0
ret re_config1:
jb flag,re_config11
jmp collect_t2
re_config11:
mov a,#0cch
call write_18201
mov a,#04eh
call write_18201
mov a,#00h
call write_18201
mov a,#00h
call write_18201
mov a,#1fh
call write_18201
ret
get_temp1:
setb p1.0
call init_18201
jb flag,tss1
jmp collect_t2
tss1:
mov a,#0cch
call write_18201
mov a,#044h
call write_18201
call init_18201
mov a,#0cch
call write_18201
mov a,#0beh
call write_18201
call read_18201
mov tempvalue_1,a
jmp collect_t2
write_18201:
mov r0,#8
clr c
wr1:
clr p1.0
mov r3,#6
djnz r3,$
rrc a
mov c,p1.0
mov r3,#23
djnz r3,$
setb p1.0
nop
djnz r0, wr1
setb p1.0
ret
read_18201:
mov r2,#8
re1:
clr c
setb p1.0
nop
nop
clr p1.0
nop
nop
nop
setb p1.0
mov r3,#7
djnz r3,$
mov c,p1.0
mov r3,#23
djnz r3,$
rrc a
djnz r2,re1
ret
collect_t2: init_18202:
setb p1.1
nop
clr p1.1
mov r0,#06bh
tsr21:
djnz r0,tsr21
setb p1.1
mov r0,#25h
tsr22:
jnb p1.1,tsr23
djnz r0,tsr22
jmp tsr24
tsr23:
setb flag
jmp tsr25
tsr24:
clr flag
jmp tsr27
tsr25:
mov r0,06bh
tsr26:
djnz r0,tsr26
tsr27:
setb p1.1
ret
re_config2:
jb flag,re_config21
ret
re_config21:
mov a,#0cch
call write_18202
mov a,#04eh
call write_18202
mov a,#00h
call write_18202
mov a,#00h
call write_18202
mov a,#1fh
call write_18202
ret
get_temp2:
setb p1.1
call init_18202
jb flag,tss2
ret
tss2:
mov a,#0cch
call write_18202
mov a,#044h
call write_18202
call init_18202
mov a,#0cch
call write_18202
mov a,#0beh
call write_18202
call read_18202
mov tempvalue_2,a
ret
write_18202:
mov r0,#8
clr c
wr3:
clr p1.1
mov r3,#6
djnz r3,$
rrc a
mov c,p1.1
mov r3,#23
djnz r3,$
setb p1.1
nop
djnz r0, wr3
setb p1.1
ret
read_18202:
mov r2,#8
re2:
clr c
setb p1.1
nop
nop
clr p1.1
nop
nop
nop
setb p1.1
mov r3,#7
djnz r3,$
mov c,p1.1
mov r3,#23
djnz r3,$
rrc a
djnz r2,re2
ret
value_txd:
mov a,tempvalue_1
call value_txd1 mov a,tempvalue_2 call value_txd1
jmp start endvalue_txd1:
mov sbuf,a mov r0,0ffhvt1: djnz r0,vt2vt2: jb ti,vt1 clr ti ret
一周热门 更多>