Continue to Site

Welcome to EDAboard.com

Welcome to our site! EDAboard.com is an international Electronics Discussion Forum focused on EDA software, circuits, schematics, books, theory, papers, asic, pld, 8051, DSP, Network, RF, Analog Design, PCB, Service Manuals... and a whole lot more! To participate you need to register. Registration is free. Click here to register now.

My solution to performing soft reset in 8051, please advise

Status
Not open for further replies.

seemanta

Member level 4
Joined
Jun 10, 2006
Messages
71
Helped
3
Reputation
6
Reaction score
1
Trophy points
1,288
Activity points
1,968
Hi,
In my system, I need to perform a soft reset for a particular condition from within an interrupt handler. I have multiple interrupt handlers so I have no idea up to how many levels all the interrupt handlers have been nested.

However, at all costs, I need to perform the soft reset and restart my system as if it has been just powered up.

My solution is as follows:
Code:
                                      ORG 0000H
                                      LJMP MAIN ;

                                      ORG 0003H ;/INT0 ISR
                                      LCALL MY_ISR
                                      RETI

MAIN:                                ...
                                     ...
                                     ...

MY_ISR:                             ...
                                     ...
                                     ...
                                     MOV 08,#00H
                                     MOV 09,#00H
                                     RET

I have ensured that here, the RETI instruction goes to the start of the program by loading the PC from the contents of RAM addresses 08 and 09.

I have tested this and it seems to work, but I am not sure if I am missing
something important here.

Would be grateful if someone in this board points out any mistakes if any, in the above code.

regards,
Seemanta
 

Re: My solution to performing soft reset in 8051, please adv

ORG 0003H ;/INT0 ISR
LJPM 00h
 

Re: My solution to performing soft reset in 8051, please adv

Hi,
If it is in continuation with your earlier thread of Power Down mode of CPU, you do not have to do any more soft reset. After servicing the interrupt as usual, your controller will directly go to the instruction just following the Sleep instruction and all your RAM and registers will be kept in tact. You can just use one NOP at this place, since somewhere it is mentioned that the instruction should not be one which writes to a memory location. It will in effect be a time skipping operation by the controller.

If it is for some other purpose, you can POP out two bytes from the stack and PUSH in the two byte address where you want to jump to, to the stalk, within the interrupt routine. But in this case, this switching will take place every time this interrupt occurs.

Regards,
Laktronics
 

Re: My solution to performing soft reset in 8051, please adv

No it is not regarding power down. I need to perform a soft reset and that too everytime I call this interrupt.

Speaking of power down mode, as per the data sheet of AT89S52, I just need an external interrupt to come out, right?

But my code is not working, for some reason and I am not able to explain why.
Maybe I shall post my code in a separate thread if I am not able to fix this myself.

regards,
Seemanta
 

Re: My solution to performing soft reset in 8051, please adv

Hi,
You can then implement a soft reset by Poping out two bytes from the stack and Pushing on the two bytes ( I suppose Low Address followed by High Address?) of Power-on Main routine to the stalk within the interrupt routine. By doing so, you can avoid unwanted filling of stalk with two unused address bytes every time you get this interrupt. After the interrupt , you will automatically go to the Reset start-up routine with this scheme.

Yes, you can come out of Sleep mode in 89S52 through an external interrupt, I thought I have read you saying that the interrupt scheme is working fine. By the way, you should not put any looping routine immediately following a Sleep instruction, as I rember having seen it some where, because, after executing the interrupt, the program will go to the instruction just following the Sleep instruction and will simply get stuck there. You can put a NOP there followed by any other program, or a jump to such a program you want to execute after sleep mode is over. It is also advisable not to put an instruction for a memory write or I/O write immediately following the Sleep instruction, as I vaguely remember. What problem are you facing with Sleep mode?
Regards,
Laktronics
 

Status
Not open for further replies.

Part and Inventory Search

Welcome to EDABoard.com

Sponsor

Back
Top