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

Regarding startup file

Hello, I written simple c program mention below by selecting the lpc2148 chip but not include its startup file in the project. when i run it will go in infinite loop. I also put the break point but i think its not coming to that execution line. Is it necessary to include startup file?
void main()
{ int a=2,b=3,c; c= a+b;
}

Parents
  • But I didn't guess.

    The question itself is also meaningless because it isn't accompanied with a proper definition of what a startup file really is.

    If it is the file that contains the first instructions the processor should run, then it obviously has to be there - if not, then the processor would either have zero instructions or would have instructions only at a place it doesn't know how to reach.

    If a "startup file" is considered an assembler file that sets up the environment, then the answer is no. A Cortex-M3 can manage with C functions for interrupt handlers, and for initialize the processor. The processor itself sets up an initial stack. So the same source file that contains main() can contain a C function that initializes RAM, sets up a heap, configures the oscillators, etc. The only special about this function is that it is called before main(), and the hardware state does not fulfill the requirements of the C standard regarding global variables or access to runtime library.

    In the end, the question can only be answered if the question is expanded to actually tell what is specifically intended with the question.

    You want to block all C questions and only allow questions relative to Keil/ARM issues. But while a startup file is outside the scope on a PC, because anything before main() is basically irrelevant, it is not so for embedded prorams.

    Keil can't know what requirements the hardware has.
    And on the other hand, Keil supports Cortex chips.

    So in the end, it is very relevant to know what is the normal requirements from a startup file - the user is likely to have to modify a startup file supplied by Keil.

    And on the other hand, you can have C-only startup code.

Reply
  • But I didn't guess.

    The question itself is also meaningless because it isn't accompanied with a proper definition of what a startup file really is.

    If it is the file that contains the first instructions the processor should run, then it obviously has to be there - if not, then the processor would either have zero instructions or would have instructions only at a place it doesn't know how to reach.

    If a "startup file" is considered an assembler file that sets up the environment, then the answer is no. A Cortex-M3 can manage with C functions for interrupt handlers, and for initialize the processor. The processor itself sets up an initial stack. So the same source file that contains main() can contain a C function that initializes RAM, sets up a heap, configures the oscillators, etc. The only special about this function is that it is called before main(), and the hardware state does not fulfill the requirements of the C standard regarding global variables or access to runtime library.

    In the end, the question can only be answered if the question is expanded to actually tell what is specifically intended with the question.

    You want to block all C questions and only allow questions relative to Keil/ARM issues. But while a startup file is outside the scope on a PC, because anything before main() is basically irrelevant, it is not so for embedded prorams.

    Keil can't know what requirements the hardware has.
    And on the other hand, Keil supports Cortex chips.

    So in the end, it is very relevant to know what is the normal requirements from a startup file - the user is likely to have to modify a startup file supplied by Keil.

    And on the other hand, you can have C-only startup code.

Children