Change Register Bit Field Configurations using Bit Positions

The example below shows how to update a register bit field using bit positions to set the new configuration. Similar to the process of updating a register configuration using bit masks, the current configuration must be cleared and the new configuration set, in a single line of code.

/* Changing a bit field configuration with bit positions */
T0CON0 = (T0CON0 & ~_T0CON0_T0OUTPS_MASK) | (0 << _T0CON0_T0OUTPS3_POSITION)
                                          | (1 << _T0CON0_T0OUTPS2_POSITION)
                                          | (1 << _T0CON0_T0OUTPS1_POSITION)
                                          | (1 << _T0CON0_T0OUTPS0_POSITION);
Note: The (0 << _T0CON0_T0OUTPS3_POSITION) line is added simply for readability, but it can be removed.
T0CON0 = (T0CON0 & ~_T0CON0_T0OUTPS_MASK) | (1 << _T0CON0_T0OUTPS2_POSITION)
                                          | (1 << _T0CON0_T0OUTPS1_POSITION)
                                          | (1 << _T0CON0_T0OUTPS0_POSITION);