??? 04/27/07 11:27 Modified: 04/27/07 11:28 Read: times |
#138099 - why \"somehow\"? Responding to: ???'s previous message |
Jani Tuomola said:
I found the solution. It was that TI, since I didn't use it on the serial ISR it somehow confused the program. I did the code so that it uses ISR TI and it works now. Why somehow? I would be nervous if I'd symptomatically remove an error and didn't know the mechanism how it worked... In this case, in the initialisation section, by SCON = 0x52 you set TI. This then remained set virtually infinitely - the only place where it got cleared was just before sending an another character, which in turn would set it again once the character is set. But I believe this never happened - see in the following, why - (unless RI got active, in which case it sent out the "RI" and fell into TI set state again). After both EA and ES were set, the set TI causes the serial interrupt is entered; and as TI is not cleared in it, it is entered over and over and again. Only one instruction is executed from main between each successive interrupts - and the same-level but lower-priority timer interrupt gets never executed... Btw., this ("never set TI (including implicit setting in putchar/printf) if you enable serial interrupts") could be made an item in the (nonexistent) "C-gotcha" list... (*) JW ---- (*) ... if there would be such a list, the compiler could be modified so that it would issue a sort of a warning or hint... (sigh) |
Topic | Author | Date |
Serial ISR and TIC or Timer 2 | 01/01/70 00:00 | |
Calling printf from within an ISR... | 01/01/70 00:00 | |
It is worse than that | 01/01/70 00:00 | |
Cross-Reference | 01/01/70 00:00 | |
Serial interrupt | 01/01/70 00:00 | |
Thanks to you all again | 01/01/70 00:00 | |
why \"somehow\"? | 01/01/70 00:00 | |
Nothing to do with 'C'? | 01/01/70 00:00 | |
why "C" | 01/01/70 00:00 | |
made it a FAQ | 01/01/70 00:00 | |
Nothing wrong with setting TI![]() | 01/01/70 00:00 |