标题:大家帮帮忙看看这个程序还有哪些问题啊!SOS!
|
|
| 大家帮帮忙看看这个程序还有哪些问题啊!SOS! |
|
|
大家帮帮忙看看这个程序还有哪些问题啊!sos! 利用p3.5按键来依次控制p1.0~p1.7
id equ 30h sp1 bit p3.5 l1 bit p1.0 l2 bit p1.1 l3 bit p1.2 l4 bit p1.3 l5 bit p1.4 l6 bit p1.5 l7 bit p1.6 l8 bit p1.7
org 0000h mov id,#00h
start:jb p3.5,ch lcall delay10ms jb p3.5,ch inc id mov a,id cjne a,#08,ch mov id,#00h ch: jnb p3.5,$
mov a,id
is0:cjne a,#00h,is1 cpl l1 sjmp start
is1: cjne a,#01h,is2 cpl l2 sjmp start
is2: cjne a,#02h,is3 cpl l3 sjmp start
is3: cjne a,#03h,is4 cpl l4 sjmp start
is4: cjne a,#04h,is5 cpl l5 sjmp start
is5: cjne a,#05h,is6 cpl l6 sjmp start
is6: cjne a,#06h,is7 cpl l7 sjmp start
is7: cjne a,#07h,is8 cpl l8 sjmp start
is8: ljmp start
delay10ms:mov r6,#20 loop1:mov r7,#248 djnz r7,$ djnz r6,loop1 ret
end
|
|
|
目前通过接电平转换之后驱动led,按p3.5低电平,p1~p7依次点亮led,每次p3.5低电平只有一个led亮,而且是顺序循环。
而现在程序运行情况是,p1亮过之后p2亮,p1有时还亮着,怎么搞的啊?郁闷死了! |
|
|
id equ 30h sp1 bit p3.5 l1 bit p1.0 l2 bit p1.1 l3 bit p1.2 l4 bit p1.3 l5 bit p1.4 l6 bit p1.5 l7 bit p1.6 l8 bit p1.7
org 0000h mov id,#00h
start:jb p3.5,$ lcall delay10ms jb p3.5,start inc id mov a,id cjne a,#08,ch mov id,#00h
ch: jnb p3.5,$
mov a,id
is0:cjne a,#00h,is1 mov p1,#0ffh clr l1 sjmp start
is1: cjne a,#01h,is2 mov p1,#0ffh clr l2 sjmp start
is2: cjne a,#02h,is3 mov p1,#0ffh clr l3 sjmp start
is3: cjne a,#03h,is4 mov p1,#0ffh clr l4 sjmp start
is4: cjne a,#04h,is5 mov p1,#0ffh clr l5 sjmp start
is5: cjne a,#05h,is6 mov p1,#0ffh clr l6 sjmp start
is6: cjne a,#06h,is7 mov p1,#0ffh clr l7 sjmp start
is7: cjne a,#07h,is8 mov p1,#0ffh clr l8 sjmp start
is8: ljmp start
delay10ms:mov r6,#20 loop1:mov r7,#248 djnz r7,$ djnz r6,loop1 ret
end |
|
|
改了改,自己对比一下修改过的地方吧
不知你的led是高电平驱动还是低电平驱动,如果是高电平的话,就将 clr l? 改成 setb l? , mov p1,#offh 改成 mov p1,#o0h
「该帖子被 青竹 在 2006-4-14 15:31:35 编辑过」 |
|
|
真是感谢!我马上就去看看! |
|
|
|
|
ok!非常不错,我怎么没想到呢?
以后还得向高手学习学习,万分感谢啊! |
|
|
|
|
[ 1 ]
|
|
共 1 页 7 条主题,当前第 1 页 |
|
|
|