I'd like to reposition my code so all code starts at 0800h. The only things I want below that are the startup vector and interrupt vectors. Am I right in assuming that the vector at locn 0000 (actually an LJMP address) cannot be relocated as this is the start point after a reset? Is it also true that the interrupt vectors are similarly fixed? Using uVision.
Am I right in assuming that the vector at locn 0000 (actually an LJMP address) cannot be relocated as this is the start point after a reset? Is it also true that the interrupt vectors are similarly fixed? yes, it's hardware defined
Erik is correct, the reset and interrupt vector are hardware but the interrupt vector table can be relocated at some higher memory. You cannot relocate the reset vector. It's a three byte location that holds a LJMP to the start up location.
For relocating the remaining vectors see the examples in the MON51 documentation.
Bradford
No, it can't.
An ISR is entered via a hardware-generated LCALL instruction - so the vector location is fixed in the hardware. The vectors have to be present at locations starting at 0x0003
See p17 in the 80C51 Family Hardware Description - Chapter 3 of the so-called "bible" for the 8051:
www.nxp.com/.../80C51_FAM_HARDWARE_1.pdf
www.8052.com/.../120112
When the Keil tools talk about "redirecting" interrupt vectors, that's really just "forwarding" from the standard location on to some other location - there still has to be a vector table present at locations starting at 0x0003.
eg, see: http://www.keil.com/support/docs/132.htm
"No, it can't"
Unless your particular target has some specific hardware feature to do it; eg, http://www.keil.com/support/docs/2286.htm
Thanks for the replies. Wirt respect to the relocation of the code is it as simple as changing the CSEG at 0 to CSEG at 0800?
.
Steve and Erik; Please read this app note on relocating your code and the interrupt vector table as defined in the startup.a51 or whatever startup code your device uses. Erik is attempting to confuse you with the hardware vector points and interrupt jump table. Go by Keil's definition if you are going to read their manuals. And as mentioned in a previous post, look at the MON51 information on relocating your vector table.
http://www.keil.com/appnotes/files/apnt_104.pdf
if you relocate the vectors to, say, 0x800 there will/must be in location 0 be a ljmp 0x800.
Erik
Erik; Please read the app note. You will see that an entry (x0000) in startup.a51 will contain an LJMP to the location defined either in startup.a51 or at the location the user can define in the uVision IDE. In both cases it will result in creating a new vector jump table and setting the reset LJMP destination location. Bradford
Sorry! Can't type hex correctly. Should be 0x0000.
Thanks for that. A useful document. I actually need to have two pieces of code, one (main) piece starting at (e.g) $1000 and the other starting at $0080. I'm using an Atmel 89C51RC2 flash based device and I'm seeing some product returned with the first half page of Flash (0000 to 007F) corrupted to FF. I've determined that this is probably due to poor power supply management. A solution would require some hardware modification which will happen at the next cycle of product review but I need to find a software solution for now. I thought that if I put a piece of code at $0080 (immediately after the area that I've seen corrupted) which rewrites the vectors at the bottom of page zero I can recover the situation. I already use the 'write to flash' routines built into the RC2. 'FF' is a benign instruction which sets up one of the registers so I recon that when the processor starts running from 0000 it will eventually hit the code at $0080, correct the corrupt flash and restart itself. An uncorrupted chip will never see the extra code as it will have a correct reset vector taking it to (e.g) $1000. Does this sound plausible (or possibly naive)?
I've determined that this is probably due to poor power supply management more likely the abscence of a supervisor chip.
Please read the app note. You will see that an entry (x0000) in startup.a51 will contain an LJMP to the location defined either in startup.a51 or at the location the user can define in the uVision IDE. In both cases it will result in creating a new vector jump table and setting the reset LJMP destination location. of course, it does. But that is NOT what I refer to. If you locate the vector table anywhere but at 0.... there will STILL be a (call it a 'shadow') vector table at 0x00 .....
there have been several posts in the past that assumed that relocating the vector table actually relocated it, i.e. power on would not affect address 0x0000
Thanks for all the comments. I have so far not got the code relocated and all vectors produced in zero page. I have changed the CSEG AT 0 in STARTUP.A51 to CSEG AT 1000h. Also set the Code Address in the linker to $1000. This produces the correct interrupt vectors in zero page pointing within code that starts at $1000. BUT the reset vector is at $1000 and points to code at $1003. It is not placed in zero page! How do I achieve this?
I have tried this from the Knowledgebase http://www.keil.com/support/docs/76.htm But I used $1000 as my code start address. This produced a reset vector at $1000, Interrupt vectors from $1003 and code after the int vectors. I figured I didn't need the interrupt vectors relocated to set the interrupt vector offset back to zero. This produced a reset vector at $1000, interrupt vectors at $0003 and code at $1003 (after reset vector.) I have played around with the C51 and BL51 options and cannot get ALL vectors in zero page and code from $1000. The only way I have found of achieving this is by setting CSEG AT 0 in STARTUP and location the code at $1000 in the BL51 size/location. This doesn't seem right to me. I have yet to test it as I don't have my programmer at the moment.