$INIT | $INITIALIZE - Define start-up initializations

Language reference ›› Directives ››
Parent Previous Next

initialize-directive = ( $INIT | $INITIALIZE ) init-all-items | init-some-items .
init-all-items = ALL .
init-some-items = init-item { "," init-item } .
init-item = ANALOGS | COMPARATORS | RAM | INTERRUPTS | ports-item .
ports-item = PORTS [ INPUT | OUTPUT ] .


Initialize some processor features at start-up (reset).


ALL:

Include all possible initializations (see below).


<init-item>:

May be one of the following:


ANALOGS:

Initializes the values of all analog control registers so that the processor is ready to make digital i/o on all of its pins.

Depending on the processor, this action may include one or several registers among ANSEL *, ADCON * and ANCON*.

Depending on the processor, digital I/O may need to initialize COMPARATORS too, see below.


COMPARATORS:

Initialize the values of all comparators control registers so that all I/O as digital is possible.

Depending on the processor, this action may include only CMCON* registers.


RAM:

Initialize all used RAM variables to zero (only explicit variables that have no initial values).

By default PMP does not initialize memory. Note that if used, all the HEAP memory pointers / structures are always reset during start-up.


INTERRUPTS:

Initialize all interrupt registers to zero.

Depending on the processor this action may include one or several registers among INTCON*, PIE* and PIR*.


PORTS [ INPUT | OUTPUT ]:

Initialize the i/o ports and direction registers.

If INPUT is specified or by default, set all LATx or PORTx registers to zero then initialize all TRISx registers to $FF (all inputs); otherwise, set all LATx or PORTx registers to zero then initialize all TRISx registers to $00 (all outputs).



WARNING! (V2.1): Previously this directive superseded a previous one (the last one was setting initialization flags and any previous $INIT declarations was discarded). Since V2.1, each $INIT directive may set several options without changing previous ones. If an option is set twice, a warning message is generated.


{$INIT COMPARATORS, ANALOGS}
{$INIT RAM}