Discussion in "8051 Discussion Forum" started by    shawn    Dec 20, 2007.
Thu Dec 20 2007, 11:20 pm
#1
Hi,
I'm new to the 8051 and was trying to figure out how to reload a program after an interrupt.
Basically, I got a program that displays something on lcd, once an interrupt is activated, it displays a different message. But once the interrupt is cleared, the interrupted message is still there. I want it to revert back to the original message once interrupt clears. How do I do that?
Please give code example and explain.
Thank you,
Thu Dec 20 2007, 11:27 pm
#2
wat u mean by program reload..?
u can make two methods like

activeInterrupt()
{
showMsg("xyz");
}
noInterrupt()
{
showMsg("abc");
}
:-|
Thu Dec 20 2007, 11:30 pm
#3
Is that in C? I need to do i tin Assembly.
Need it to say hello if not activate and bye when activated and go back to hello once interrupt is deactivated.
Here is my code:
Here's my example program, please make correction to it:
org 0h

LJMP MAIN

;ISR for Interrup INT 0 for Part 2:
ORG 0013H
Mov a, #38H
acall command
acall delay
Mov a, # 0EH
acall command
acall delay
Mov a, # 01H
acall command  
acall delay          
Mov a, # 06H
acall command
acall delay
Mov a, # 80H                
acall command
Mov a, # 'B'			
acall datadisplay 
acall delay                      
Mov a, # 'Y'			
acall datadisplay
acall delay
Mov a, # 'E'			
acall datadisplay
acall delay
hold:
sjmp hold
reti

MAIN:
Mov a, #38H
acall command
acall delay
Mov a, # 0EH
acall command
acall delay
Mov a, # 01H
acall command  
acall delay          
Mov a, # 06H
acall command
acall delay
Mov a, # 80H                
acall command
acall delay
Mov a, # 'H'			
acall datadisplay
acall delay
Mov a, # 'E'			
acall datadisplay
acall delay
Mov a, # 'L'
acall datadisplay
acall delay
Mov a, # 'L'
acall datadisplay
acall delay
Mov a, # 'O'
acall datadisplay
acall delay

Mov IE,#10000101B
stay:	sjmp stay

delay:
mov r3, #50 
here2: mov r4,#255
here: djnz r4, here
	djnz r3, here2
ret

command: ;to use in LCD
mov p1,a 
clr p2.0 ;make RS 0 to execute command code on LCD
clr p2.1 ;make R/W 0 for writing 
setb p2.2
acall delay
clr p2.2
ret
datadisplay: ;to display data on LCD
mov p1,a
setb p2.0 ;make RS 1 to execute data display on LCD
clr p2.1 ;make R/W 0 for writing
setb p2.2 ;high-to-low pulse to E pin of LCD 
acall delay
clr p2.2
ret
end


[ Edited Fri Dec 21 2007, 12:10 am ]
Thu Dec 20 2007, 11:41 pm
#4
fyi,
I believe the correct quote is:
A journey of a thousand miles begins with a single step. by Confucius
Thu Dec 20 2007, 11:49 pm
#5
hey shawn.....
thats no ConFUcious .. we dont know him....
we know Abbas so
"A Thousand Miles Journey Starts With a Single Step"
is the correct one
Thu Dec 20 2007, 11:51 pm
#6


fyi,
I believe the correct quote is:
A journey of a thousand miles begins with a single step. by Confucius

shawn


maybe....
but here semantics is more important than syntax .......:):):)
Fri Dec 21 2007, 12:07 am
#7
I guess those who stand on toilets are high on pot!

back to subject,
any suggestion to make my program run like I want it to?
I've tried just about everything I know of, but can't seem to figure it out.
Any help would be appreciated,
Thanks!
Fri Dec 21 2007, 12:17 am
#8
shawn .....
once the irq is over..............
the code returns back to.........

stay: sjmp stay


so u r not updating lcd..............
u wont get hello...........
so in the infinite loop call the programme to display again and it will be done

I guess those who stand on toilets are high on pot!



wht does that mean???
hope u r taking it lightly


 shawn like this.
Fri Dec 21 2007, 12:17 am
#9
instead of using this statement..
stay:   sjmp stay


create a status bit.. say "interrupted".
interrupted bit 0H

When interrupt occurs set the bit.. and when the bit is set jump to start of program..

so you can replace the above statement by this..

stay: jnb interrupted, stay
sjmp main


and make sure to clear this bit at the start of main routine and set it in the interrupt service routine.


[ Edited Fri Dec 21 2007, 12:20 am ]
 shawn like this.
Fri Dec 21 2007, 12:37 am
#10
didn't work, all that did was repeat hello, but doesn't return to hello once deactivated.
Switched loop command into isr and working good.
Thanks guys!

Get Social

Information

Powered by e107 Forum System

Downloads

Comments

Michailqfh
Fri Mar 29 2024, 01:53 am
Bobbyerilar
Thu Mar 28 2024, 08:08 am
pb58
Thu Mar 28 2024, 05:54 am
Clarazkafup
Thu Mar 28 2024, 02:24 am
Walterkic
Thu Mar 28 2024, 01:19 am
Davidusawn
Wed Mar 27 2024, 08:30 pm
Richardsop
Tue Mar 26 2024, 10:33 pm
Stevencog
Tue Mar 26 2024, 04:26 pm