Register Initialization using Bit Unions

Register initialization using bit and bit field unions will always need to be done in several lines of code, if configuring more than one bit or bit field.

The example below shows the recommended way of initializing a register, by using the union declaration of the register from the header file.

T0CON0bits.T0EN = 1;      /* Enable TMR0 */
T0CON0bits.T016BIT = 0;   /* Select 8-bit operation mode */
T0CON0bits.T0OUTPS = 0x9; /* Select 1:10 postscaler */