Crossware

Table of Contents        Previous topic       Next topic       

Code Creation Wizards->_init_chip() and _init_chip1()

There are two predefined functions in xstdsys.c.  These are _init_chip() and _init_chip1().  The functions are initially empty and the wizards optionally add configuration code to them in response to your commands.

Both of these functions are called from assembler source file startup.asm.  _init_chip() is called before any calls that initialise any C variables and _init_chip1() is called after this C initialisation process.

_init_chip() is the appropriate place for code that must be executed before the C initialisation process  such as memory configuration code, code to disable the watchdog timer if it is enabled at reset and possibly code to initialise the oscillator so that the C initialisation process can take place at maximum speed.

Configuration code that is not critical to the C initialisation process can go into _init_chip1() and because the C initialisation process has already taken place C variables can be used with the knowledge that they will have been correctly initialised.