| ??? 01/29/03 06:36 Read: times |
#37602 - register protection in 8051 |
i have the problem regarding the register values getting corrupted while using interrupt. i know that the registers used in the main program have to be protected using push and pop instructions.
the problem is , the registers used in the interrupt routene is getting corrupted here is the program using timer0 to genetrate pwm. pwm: clr et0 ;pulse width generation clr tr0 setb ea mov a,#00h mov r5,#00h mov tmod,#01h mov tl0,1ch mov th0,1dh setb et0 setb tr0 label : cjne ,#04h,$ ;generate4pulses ;then,go to main program main program ;loading timer clr et0 clr tr0 mov 1ch,#00h ;off time low byte mov 1dh,#0ffh ;off time high byte mov 1eh,#00h ;on time low byte mov 1fh,#0ffh ;on time highbyte ajmp pwm org 000bh clr tr0 clr et0 clr a mov a,r4 cpl a mov r4,a ;if A=0, then jump to ontime value. mov p1,a ;if A=1, then jump to off time value cjne a,#00h,on mov a,r5 inc a mov r5,a mov tl0,1ch mov th0,1dh setb tr0 setb et0 reti on: mov tl0,1eh ;on time low byte mov th0,1fh setb tr0 setb et0 reti here the register values , r5 , 1c,1d,1e,1f are getting corrupted while in the loop. it works well for some time. then it is getting corrupted. please clear it. |
| Topic | Author | Date |
| register protection in 8051 | 01/01/70 00:00 | |
RE: register protection in 8051 | 01/01/70 00:00 | |
| RE: register protection in 8051 | 01/01/70 00:00 | |
| RE: register protection in 8051 | 01/01/70 00:00 | |
| RE: register protection in 8051 | 01/01/70 00:00 | |
| RE: register protection in 8051 | 01/01/70 00:00 | |
| RE: register protection in 8051 | 01/01/70 00:00 | |
| RE: register protection in 8051 | 01/01/70 00:00 | |
| RE: register protection in 8051 | 01/01/70 00:00 | |
| RE: register protection in 8051 | 01/01/70 00:00 | |
| RE: register protection in 8051 | 01/01/70 00:00 | |
| RE: register protection in 8051 | 01/01/70 00:00 | |
| RE: register protection in 8051 | 01/01/70 00:00 |



