??? 08/09/10 03:39 Read: times |
#177896 - Assembler if you want Responding to: ???'s previous message |
Andy Neil said:
But the 'interrupt' keyword causes the Keil C51 compiler to put a RETI at the end of onSerialPortISR - instead of RET.
So you will end up having two RETIs for one interrupt... Really, if you're going to do these kind of tricks, you need to be doing it in assembler! Ah yes, in assembler it is easy, but it can be done in C. I had been relying on failing human memory, instead of looking it up. The principle is there, and it works, but my memory was faulty. I had to look it up. In main SP = x Serial int In SerialISR SP = x + 2 void Serialint (void){ .... //TX part sendchar(char ch); } void sendchar (char ch){ freeint(); ... } void freeint (void){ #pragma asm reti #endpragma asm } In sendchar SP = x+4 In Freeint SP = x+6 Reti SP = x + 4 = sendchar ret from sendchar SP = x+2 In serialISR reti from serialISR SP = x Back at main You are correct, the reti will be done twice. The point is that reti is the same as ret software wise, but additionally it handles the hardware interrupt unlock. So you unlock the interrupts twice. No problem. References: http://www.embedded.com/columns/t.../190302110 www.state-machine.com/8051/QDKn_8051-IAR.pdf Regards Johan Smit |
Topic | Author | Date |
Writing to SBUF in Serial Routine | 01/01/70 00:00 | |
Sure... | 01/01/70 00:00 | |
yes, but | 01/01/70 00:00 | |
TX inside serialint | 01/01/70 00:00 | |
Pardon?? | 01/01/70 00:00 | |
Pardon accepted | 01/01/70 00:00 | |
Still a Missing Part of Scheme | 01/01/70 00:00 | |
Pardon | 01/01/70 00:00 | |
Will that work in 'C' ? | 01/01/70 00:00 | |
Assembler if you want | 01/01/70 00:00 | |
Why send_char? | 01/01/70 00:00 | |
Why send_char | 01/01/70 00:00 | |
You missed the point | 01/01/70 00:00 | |
Call a routine from an interrupt | 01/01/70 00:00 | |
Still misunderstanding | 01/01/70 00:00 | |
misunderstandings![]() | 01/01/70 00:00 | |
what happened to the OP? | 01/01/70 00:00 |