I have noticed that the Kiel compiler doesn't produce the correct interrupt vector if 8051 interrupt numbers are used. For example for external interrupt 0 (IE0), the interrupt number has to be 0, instead of 1 to produce a jump at location 1. Example:
void edge1 (void) interrupt 0{ /*produces correct code
while
void edge1 (void) interrupt 1{ /*produces wrong code
This is the case with all the interrupts I have used. My questions is what do you have to do to produce a reset vector? Reset is interrupt number 0 in 8051 numbering. Using -1 or 255 both produce a compile error.
How about reading the compiler manual:
http://www.keil.com/support/man/docs/c51/c51_le_interruptfuncs.htm
My questions is what do you have to do to produce a reset vector?
you can't, THE '51 CAN NOT BE RESET 'BY VECTOR'
If address 0 was interrupt 0 you could restart the processor, but the SFRs would not default.
to reset the processor you can time out a watchdog, some derivatives have a SFR bit that will cause a reset, but just a jump to 0 will not do.
Erik
Of course a vector will not reset an 8051, the very idea is ridiculous. A vector is the address the 8051 jumps to in response to an interrupt. The reset vector for an 8051 is address 0. Reset is a non-maskable event that occurs when the reset line is asserted. The Kiel compiler doesn't have any way of producing code for the reset vector using the interrupt statement. The EX0 vector is 3. Reading the manual doesn't provide any new information. No mention is made of how to code the reset vector. Comparing the table on that manual page to 8051 chip docs, the interrupt numbering is off by 1, as I mentioned above. Instead of starting at reset (0), it starts at EX0 (which is 1 in the 8051 chip docs). There are other ways of course.
Of course a vector will not reset an 8051, the very idea is ridiculous.
He's a master of the art of misunderstanding, just ignore him.
If you want to modify what happens on reset the place to do would be in startup.a51. In the normal course of things you wouldn't want to, though, as the startup and initialisation code needs to run before your main() is entered. The 'interrupt' keyword is only for use with interrupt handlers so it seems fairly reasonable that it won't allow a vector to be inserted at location zero.
Is it?
Where did you see that defined?
The so-called "bible" for the 8051 never considers reset as an interrupt.
Neither does it use any concept of interrupt "numbers" - it speaks only of the vector addresses.
The C51 interrupt numbers are a Keil invention as part of their interrupt keyword extension in C51 - you cannot put any other meaning on them other than defined in the Keil C51 manual!
.
However, this is a regular FAQ due to the following quote from the document you refer to:
Source Priority Within Level 1. IE0 (highest) 2. TF0 3. IE1 4. TF1 5. RI+TI (lowest)
Yet another post from you with useful content, I see.
"this is a regular FAQ due to the following quote from the document you refer to"
I don't see how that has anything to do with interrupt numbers - and it certainly doesn't suggest that reset is "interrupt 0".
please expand...
Oh dear. You said:
I said:
You have now responded with:
The point is this:
The 8051 documentation does assign numbers to the interrupts. These numbers reflect each interrupts priority level.
Keil assign numbers to the interrupt vectors which happen to be the priority level (as enumerated in the above table) minus one. This causes regular confusion as the two concepts are, probably fairly reasonably, confused. It would probably have been a better choice if Keil had used the numbering from the above table.
The idea of the reset vector being somehow 'interrupt 0' is not inferred or suggested by any of the above.
Clear?
The 8051 documentation does assign numbers to the interrupts. These numbers reflect each interrupts priority level. VERY incomplete statement and many have been led astray by this.
Correctly the statement should be: These numbers reflect each interrupts priority level for interrupts occurring in the same processor cycle
Another caveat is that some modern derivatives have 'gaps' in the interrupt vectors (usually an interrupt that another family member has) and do not have gaps in the 'interrupt numbers'
Thus the only safe way to get an 'interrupt number' is by the formula ((interrupt_vector_address/8 ) -3)
"The point is this: The 8051 documentation does assign numbers to the interrupts."
That's not my reading of that list.
My reading is that it's simply an ordered list where 1 is the highest priority, and 5 the lowest - I don't see that as "numbering the interrupts". Especially as the table you quoted is immediately followed by this note:
"Note that the 'priority within level' structure is only used to resolve simultaneous requests of the same priority level."
So the numbers are not intended to be any kind of general interrupt identifier - just an indication of priority within the context of that particular discussion.
"This causes regular confusion as the two concepts are, probably fairly reasonably, confused"
You may well be right there!
"Clear?"
I think I get what you're saying now.
"Keil assign numbers to the interrupt vectors which happen to be the priority level (as enumerated in the above table) minus one."
Pure coincidence?
More directly, Keil assign numbers to the interrupt vectors which happen to be the same as the enable bit positions in the IE register.
Probably the true rationale between the so-called "interrupt numbers" in Keil's C51 is that they are the position (index) of the vector within the vector table.
Hence the formula quoted by Erik.
That should be:
"the only safe way to get Keil's so-called 'interrupt number' for C51 is by the formula ((interrupt_vector_address/8 ) -3)"
and, in fact, it's not completely safe - as it doesn't state the upper-bound on Keil's so-called C51 "interrupt numbers".
Therefore, the only really safe way to get Keil's so-called 'interrupt number' for C51 is to Please read the manual: http://www.keil.com/support/man/docs/c51/c51_le_interruptfuncs.htm
Interrupt priority and the interrupt number are two different things. Interrupt priority can be changed by programming registers but the interrupt number is fixed. In all the chip manufacturers' documentation (TI, Atmel, Philips, etc) for 8051 variants RESET is listed as interrupt 0, with vector address 0. It would be useful to be able to program this vector with the interrupt statement in cases where the C startup code was not used. The Kiel manual section on interrupts is incomplete and misleading. It shows an interrupt as a stand-alone program, without the startup code or anything else. Normally the interrupt vector location would have a long jump (requiring all 3 bytes) to the body of the interrupt routine. That is what the compiler emits when interrupts are part of a larger program.