This discussion has been locked.
You can no longer post new replies to this discussion. If you have a question you can start a new discussion

How to disable Startup code for P89C51RD2HBP

Hi,
I am using Keil Evaluation copy, and for the first time. I am well conversant with other C-Compiler for 8051 family.

I want to disable the startup code generated by the compiler.
I have opened a new project, and disabled the option to load the startup code. But, at the address 0000, it puts the code to Jump to another small startup routine which does some initialization and initializes the stack. I do not want this code to be generated at all.
I know it sounds crazy "not to have a startupcode", but the requirement is such that I do not want the startup code at all.

My requirement is:

1. My C program must start at Location 4000h.
2. Not a single line of code/instruction between 0000h to 3fffh.
3. Initailizations such as memory clearing, or Stack initializations,etc must not be done at all, even by the program starting at 4000h.

Thanking You,
Mr. Kiran V. Sutar.

Parents
  • On the Options for target pane do the following:

    Target Tab: Don't check the Use On-Chip stuff. Select Off chip code and enter 0x4000 for a start address, 0xFBFF for the end (you don't want to clobber the IAP)

    C51 Tab: Specify the interrupt vectors at 0x4000.

    Startup.A51: Modify the program origin (CSEG AT 0) to read CSEG AT 04000H.

    Other than that, just compile and link your program normally, including the startup code.

    When I did it, I needed to write my own boot loader. The boot loader, located in the first flash page, was written the same way with the origin at address 0x0100. I wrote an assembly module that handled the routing of all interrupts by:

    IntVect Macro   Num
            CSEG    AT 8*Num+3
            Jb      InBoot,$+6
            Ljmp    4000H+(8*Num+3)
            Ajmp    0100H+(8*Num+3)
            Endm
    
            IntVect 0               ; INT0 - External Interrupt
            IntVect 1               ; T0 - Timer 0 Interrupt
    
            IntVect 2               ; INT1 - External Interrupt
            IntVect 3               ; T1 - Timer 1 Interrupt
    
            IntVect 4               ; SP - Serial Port Interrupt
            IntVect 5               ; T2 - Timer 2 Interrupt
    
            IntVect 6               ; PCA - Programmable Capture Array Interrupt
    

    You will need to handle the initial startup, setting the InBoot bit, protecting it from your application, etc.

    Keil has a nice app note on this.

Reply
  • On the Options for target pane do the following:

    Target Tab: Don't check the Use On-Chip stuff. Select Off chip code and enter 0x4000 for a start address, 0xFBFF for the end (you don't want to clobber the IAP)

    C51 Tab: Specify the interrupt vectors at 0x4000.

    Startup.A51: Modify the program origin (CSEG AT 0) to read CSEG AT 04000H.

    Other than that, just compile and link your program normally, including the startup code.

    When I did it, I needed to write my own boot loader. The boot loader, located in the first flash page, was written the same way with the origin at address 0x0100. I wrote an assembly module that handled the routing of all interrupts by:

    IntVect Macro   Num
            CSEG    AT 8*Num+3
            Jb      InBoot,$+6
            Ljmp    4000H+(8*Num+3)
            Ajmp    0100H+(8*Num+3)
            Endm
    
            IntVect 0               ; INT0 - External Interrupt
            IntVect 1               ; T0 - Timer 0 Interrupt
    
            IntVect 2               ; INT1 - External Interrupt
            IntVect 3               ; T1 - Timer 1 Interrupt
    
            IntVect 4               ; SP - Serial Port Interrupt
            IntVect 5               ; T2 - Timer 2 Interrupt
    
            IntVect 6               ; PCA - Programmable Capture Array Interrupt
    

    You will need to handle the initial startup, setting the InBoot bit, protecting it from your application, etc.

    Keil has a nice app note on this.

Children