Keil uVision
Mon Nov 23 2009, 05:31 pm
well from example you could have figured out
y is data to be sent
x is port where data is to be sent.
I already explained dave's macro is for reading, and my macro is for writing.
Do read about macros
y is data to be sent
x is port where data is to be sent.
I already explained dave's macro is for reading, and my macro is for writing.
Do read about macros
Tue Nov 24 2009, 08:39 pm
Hi
I have doubt in C programming. As when we declare interrupt(AT89C51) like...
void <name>() interrupt 0
{
//body
}
This is INT0..So as only 8 bytes is dedicated to it in Interrupt vector table. So if my ISR is more then that then what to do as in case of assembly we jump out of from that particular interrupt address. And in C it automatically manage or we have to something??
I have doubt in C programming. As when we declare interrupt(AT89C51) like...
void <name>() interrupt 0
{
//body
}
This is INT0..So as only 8 bytes is dedicated to it in Interrupt vector table. So if my ISR is more then that then what to do as in case of assembly we jump out of from that particular interrupt address. And in C it automatically manage or we have to something??
Tue Nov 24 2009, 10:46 pm
This is why we call this area a "jump table" area. It is filled with nothing more than the command:
where XXXX is an address.
Here is an example:
Suppose you have code like this:
The compiler sees these functions are interrupts, and it builds a jump table to each of these functions (at the proper place within the jump table), so that when the interrupt occurs, the micro will vector to the corresponding place within the jump table, and start executing instructions. The first instruction it executes is a jump to the beginning of the proper function.
Here is what the jump table looks like for the above code:
Notice that at address 0x0000, we have a jump to the beginning of our code. Also notice that at the beginning of the jump table ( 0x0003), we have a jump to the function ISR_0(). Eight addresses later, we have a jump to the function ISR_1(). And so on, and so on...
Now, why is there 8 addresses between each entry into the jump table? Well, if you had a very simple interrupt function, you could avoid the jump, and just put the code in the table. This could save you time for very small interrupt functions, which means more efficient code...
Now, of course, I have to ask this question: Did you read the "bible" documents for the 8051?
In the one titled "8051_FAMILY_HARDWARE.pdf", there is a very detailed description of this whole interrupt process, starting on page 16, and titled, "How Interrupts Are Handled" ( which is a pretty good description of what's to come next)...
I hope this helps,
LJMP XXXX
where XXXX is an address.
Here is an example:
Suppose you have code like this:
#define IE0_VECTOR 0 /* 0x03 External Interrupt 0 */ #define TF0_VECTOR 1 /* 0x0B Timer 0 */ #define IE1_VECTOR 2 /* 0x13 External Interrupt 1 */ #define TF1_VECTOR 3 /* 0x1B Timer 1 */ #define SIO_VECTOR 4 /* 0x23 Serial port */ void ISR_0() interrupt IE0_VECTOR { Ticker++; // bump ticker count... } void ISR_1() interrupt TF0_VECTOR { Ticker++; // bump ticker count... } void ISR_2() interrupt IE1_VECTOR { Ticker++; // bump ticker count... } void ISR_3() interrupt TF1_VECTOR using 1 { TH1 = High(Msec1); // Reset the clock for next interrupt TL1 = Low(Msec1); Ticker++; // bump ticker count... } void ISR_4() interrupt SIO_VECTOR { Ticker++; // bump ticker count... }
The compiler sees these functions are interrupts, and it builds a jump table to each of these functions (at the proper place within the jump table), so that when the interrupt occurs, the micro will vector to the corresponding place within the jump table, and start executing instructions. The first instruction it executes is a jump to the beginning of the proper function.
Here is what the jump table looks like for the above code:
C:0x0000 020240 LJMP STARTUP1(C:0240) C:0x0003 020026 LJMP ISR_0(C:0026) C:0x0006 00 NOP C:0x0007 00 NOP C:0x0008 00 NOP C:0x0009 00 NOP C:0x000A 00 NOP C:0x000B 02007F LJMP ISR_1(C:007F) C:0x000E 00 NOP C:0x000F 00 NOP C:0x0010 00 NOP C:0x0011 00 NOP C:0x0012 00 NOP C:0x0013 0200D8 LJMP ISR_2(C:00D8) C:0x0016 00 NOP C:0x0017 00 NOP C:0x0018 00 NOP C:0x0019 00 NOP C:0x001A 00 NOP C:0x001B 0201C0 LJMP ISR_3(C:01C0) C:0x001E 00 NOP C:0x001F 00 NOP C:0x0020 00 NOP C:0x0021 00 NOP C:0x0022 00 NOP C:0x0023 020131 LJMP ISR_4(C:0131)
Notice that at address 0x0000, we have a jump to the beginning of our code. Also notice that at the beginning of the jump table ( 0x0003), we have a jump to the function ISR_0(). Eight addresses later, we have a jump to the function ISR_1(). And so on, and so on...
Now, why is there 8 addresses between each entry into the jump table? Well, if you had a very simple interrupt function, you could avoid the jump, and just put the code in the table. This could save you time for very small interrupt functions, which means more efficient code...
Now, of course, I have to ask this question: Did you read the "bible" documents for the 8051?
In the one titled "8051_FAMILY_HARDWARE.pdf", there is a very detailed description of this whole interrupt process, starting on page 16, and titled, "How Interrupts Are Handled" ( which is a pretty good description of what's to come next)...
I hope this helps,
Tue Nov 24 2009, 11:08 pm
Firstly, Thanks for such reply.
OK I'll definitely read that but where I can find that 'bible' and 'pdf' you are referring.
You mean the C compiler automatically identify that if the code is large then the space allocated to particular interrupt or not. If yes then it jumps to location as you mention in above code otherwise uses the space allocated to particular interrupt.
I'm right ??
OK I'll definitely read that but where I can find that 'bible' and 'pdf' you are referring.
You mean the C compiler automatically identify that if the code is large then the space allocated to particular interrupt or not. If yes then it jumps to location as you mention in above code otherwise uses the space allocated to particular interrupt.
I'm right ??
[ Edited Tue Nov 24 2009, 11:13 pm ]
Wed Nov 25 2009, 04:30 pm
even if your ISR is small C tends to put a jump there. it never checks if your ISR is small or big. test it..
That C51 bible is located in download section under 8051 ebooks
Embedded C with Keil
That C51 bible is located in download section under 8051 ebooks
Embedded C with Keil
Wed Nov 25 2009, 09:56 pm
I m reading 8051_FAMILY_HARDWARE.pdf Interrupts. But there is word they are using like "S5P2" what does that mean....
Powered by e107 Forum System