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.

Can I change the code in running application? 8052/ 89S52

Status
Not open for further replies.

Sandy Pal

Newbie level 2
Joined
Dec 9, 2009
Messages
2
Helped
0
Reputation
0
Reaction score
0
Trophy points
1,281
Location
India
Activity points
1,303
Hi,
In my program, I'm using Register R2 & R3 around Timer0 (in timer mode), like shown below...

Code:
Delay1:              MOV R2, #10h         ; 
repeat:               MOV R3, #20h       ;
back:                   MOV TL0, #10H    ; 
                           MOV TH0, #20H ; 
                              CLR TF0      ; clear flag
                              SETB TR0       ; start timer
                              JNB TF0, $     ; stay here till flag is raised
                              CLR TR0       ; 
                          DJNZ R3, back  ; 
                          DJNZ R2, repeat ; Roll-over Timer0, till R2 & R3 =0
                          RET                 ;

The above code rolls-over timer0 200 times (10 * 20 times by R2 & R3).
Suppose, I assign P0.1 & P0.2 (which are set high) for increasing the above delay, P0.1 for R2 & P0.2 for R3, and arrange two switches which can connect P0.1 & P0.2 to Ground when pressed, is there any way to change the values in R2 & R3 during running application?:?:
i.e. if Switch1 is pressed, increment R2, ifSwitch2 is pressed, increment R3. The values, if changed during running application, should be restored even after Power is switched Off/On.
Can someone suggest some code for this?:idea:

Thanks.

Sandy
 

Re: Can I change the code in running application? 8052/ 89S5

dear sandy waht is your application your question is not clear. for storing a restoring purpose you have to use external EEPROM memory ic usch as at24c02 which can be operated using IIC protocol or you have to use the MC 89s8252 which as inbuilt EEPROM>


regards
kj.
 

To control the delay externally, the values of R2 and R3 are to be changed under external control. If this is the issue then the approach could be to to load the value from some ram location into R2 and R3. The ram locations could be modified during run time under external control.
 

Re: Can I change the code in running application? 8052/ 89S5

ark5230 said:
To control the delay externally, the values of R2 and R3 are to be changed under external control. If this is the issue then the approach could be to to load the value from some ram location into R2 and R3. The ram locations could be modified during run time under external control.

You mean, I follow something like this...

* First Load R0 & R1 with some RAM pointer (say R0= 40h & R1=41h).
* Load 10h @R0, (For R2=10h) & Load 20h @R1, (For R3=20h).
* When switch1 or switch2 is pressed, I should Increment R2 or R3.
* Then again move these values @R0 & @R1 respectively.
* Again make R2=@R0 & R3=@R1.
* This will load updated values in R2 & R3, No doubt.

But, If I change the values during running application & load those into RAM, will those values be restored after Power is switched Off/On.

I want to write to Flash ROM. Also I'm neither using any Eprom nor I wish to use any.

If the changed values are restored after Power on, then above code will definately do.

Thanks.

Sandy

:arrow: Also let me tell the purose of this excercise. Presently I'm using as many as 5 pins for selecting various time delays. I thought, doing something in the running application may relieve 3 pins, which could be used for some other function. :!:
 

Status
Not open for further replies.

Part and Inventory Search

Welcome to EDABoard.com

Sponsor

Back
Top