| ??? 03/27/02 06:29 Read: times |
#21186 - RE: Help me understand Serial interrupt? |
The only difference is that in the code that functions RI is cleared in the ISR. Can anyone explain what is happening with the ISR that would produce the errant results when RI is cleared after the program discovers GetInp is set by the ISR (both RI and GetInp are cleared simultaneously) versus when RI is cleared within the ISR?
The difference is that if you exit your serial ISR without clearing RI, your serial ISR will be called again almost immediately. The data will come in and RI will be set. The MCU will trigger the serial interrupt because RI is set. Your ISR will be executed and will exit. The MCU will execute one instruction of your "main" program and then realize the RI bit is set (because you didn't clear it) and so it will execute your serial interrupt again. When you clear the RI bit in the serial interrupt the 8052 considers the event "handled" and won't call your ISR until another byte comes in. It appears that my problem code vectors to the RI/TI ISR over and over. If you don't clear RI (and/or TI) in your serial interrupt, It does vector to your ISR over and over again. That said, you really should read SBUF in your ISR and then clear RI. Your current approach of clearing RI in the ISR and then reading the data outside of the interrupt could lead to problems. Just go ahead and read the value out of SBUF in the ISR and everything will work much better and be less complicated at the same time. Good luck, Craig Steiner |
| Topic | Author | Date |
| Help me understand Serial interrupt? | 01/01/70 00:00 | |
| RE: Help me understand Serial interrupt? | 01/01/70 00:00 | |
| RE: Help me understand Serial interrupt? | 01/01/70 00:00 | |
| RE: Help me understand Serial interrupt? | 01/01/70 00:00 | |
| RE: Help me understand Serial interrupt? | 01/01/70 00:00 | |
| Thanks and one more thing | 01/01/70 00:00 | |
| RE: Thanks and one more thing | 01/01/70 00:00 | |
| RE: Help me understand Serial interrupt? | 01/01/70 00:00 | |
| RE: Help me understand Serial interrupt? | 01/01/70 00:00 | |
| RE: Help me understand Serial interrupt? | 01/01/70 00:00 | |
| RE: Help me understand Serial interrupt? | 01/01/70 00:00 | |
| RE: Help me understand Serial interrupt? | 01/01/70 00:00 | |
RE: Help me understand Serial interrupt? | 01/01/70 00:00 |



