This forum was established for computer programmers, especally embedded programmers to ask/answer questions and share experiences in programming to make programming life less frustrating but more enjoyable.

In a MPLAB project, how do I eliminate the startup function from the lib in order to use my own startup code? I tried to delete the Library Search Path from the project build option, which I thought was the way to exclude it, however, the execution still starts from the default startup, and my startup was not invoked. Please advise.

If you specify a Library Search Path in the build option, the linker will use the lib that you specified. If you don't specify one, the linker will use the default lib (crt0, crt1 that are located in the MPLAB installation folder) according to the commands in the linker script file such as the following

OUTPUT_ARCH("30F6010A") EXTERN(__resetPRI) EXTERN(__resetALT)

to resolve three external symbols

__resetPRI __resetALT __reset

Now, if you include one startup code (you may give your file any name but not the same as crt0.s or crt1.s) into your project, and the above three symbols are declared in your file, the linker will use them from your file. For any symbol missed, the linker will use the one in the default lib. In other word, your startup code takes higher priority than the default.

To prove your startup code is used, debug your code from address 0 (you may refer to Reset to Main() Entry or Zero Address for how) and step through your code from the Program Memory window within MPLAB IDE.