| ??? 01/23/05 18:16 Read: times |
#85631 - Timer Problem Responding to: ???'s previous message |
You appear to have programmed the timer interrupt to dive right into the middle of your main stream code. This is not the way interrupts are used. The interrupt vector must point to a short block of code that handles the interrupt condition and then ends with an RETI instruction. If you do not do this the stack pointer will grow to the point of trashing your internal data space content. In addition it is necessary for the RETI to occur after the interrupt because there is some special hardware stuff that happens in the CPU core when this instruction executes. (Read the 8051 Bible in the "Links" section to learn about this issue).
It is also not normally acceptable to have other parts of your code try to call or jump to the same block of code that I described above. The conventional way to have the timer ISR (interrupt service routine - which is what the block of interrupt processing code is called) talk back to the main stream of code is to use a bit flag variable or other RAM variable. You should try to avoid having an ISR use a register (one of R0 to R7) that is also in use by the main stream code to pass information from the ISR context to the main stream context. The 8051 architecture does have the concept of multiple register banks and it is common to use these in a way where the main stream will use say register bank 0 and the interrupt context uses register bank 1. You should not need to use register banking for your short program however. You could look at the code in this link that I posted a while back that gives an example of a timer interrupt. Michael Karas |
| Topic | Author | Date |
| Hardware isnt responding | 01/01/70 00:00 | |
| Interrupt ? | 01/01/70 00:00 | |
| Delay subroutines | 01/01/70 00:00 | |
| State machines? | 01/01/70 00:00 | |
Timer Problem | 01/01/70 00:00 |



