| ??? 06/26/99 10:18 Read: times |
#533 - RE: Stack and interrupts |
After exiting your interrupt routine, it jumps to address 3040h, where you set P1, then it jumps to cold restart vector 0.
1. Never use push in your interrupt routine this way, the stack increases every interrupt by 2 so if you are using 8052, after 64 interrupts the stack gets overflown and it overrides registers for it rolls over from 0ffH --> 000H. If you want to return to different address from an interrupt routine, you should execute 2 dummy POP ACC or even better 2 times DEC SP - it is faster, before executing PUSH DPL, PUSH DPH. 2. Consider your software. After an interrupt, the stack is increased by 2 (return address), then you execute 2 PUSH instruction, so the stack pointer is in fact increased by 4. After RETI the stack pointer is 81h, and a jump to 3040H is executed indirectly. There you set P1 and jump to address 0. You initialize all over again, set serial interface, interrupts and stack pointer back to 07fh. You could execute an RET instruction after seting P1 at 3040H, so stack pointer will be decreased by 2 and an indirect jump to WAIT will be executed. Maybe there is a problem in your software (if this one is just for demonstration) that a reinitialization after an interrupt sets again the counters to initial values and so timeouts are not OK. |
| Topic | Author | Date |
| Stack and interrupts | 01/01/70 00:00 | |
| RE: Stack and interrupts | 01/01/70 00:00 | |
| RE: Stack and interrupts | 01/01/70 00:00 | |
| RE: Stack and interrupts | 01/01/70 00:00 | |
RE: Stack and interrupts | 01/01/70 00:00 |



