23.4.5.1 Asynchronous Mode TMR1 Read and Write Operations

Two bits in the TxCON register can be used to ensure that writes during timer operation will not cause the timer value to be corrupted. The TMWDIS bit in TxCON register, when set, will prevent a write to the timer and period registers when a previous write to the timer is awaiting synchronization into the asynchronous timer clock domain. The TMWIP and PRWIP bits in TxCON register indicate when write synchronization is complete and it is safe to write another value to the timer register and period register. These bits have no effect in Synchronous Clock Counter modes.

The Timer Write in Progress bit (TWIP) provides two options for safely writing to the TMRx Count register while Timer is enabled.

Option 1 is the legacy Timer Write mode, TWDIS bit = 0. To determine when it is safe to write to the TMRx Count register, it is recommended to poll the TWIP bit. When TWIP = 0, it is safe to perform the next write operation to the TMRx Count register. When TWIP = 1, the previous write operation to the TMRx Count register is still being synchronized and any additional write operations should wait until TWIP = 0.

Option 2 is the new Synchronized Timer Write mode, TWDIS bit = 1. A write to the TMRx Count register can be performed at any time. However, if the previous write operation to the TMRx Count register is still being synchronized, any additional write operations are ignored.

Note: A write to the TMRx Count register must be performed prior to configuring Timer for Asynchronous mode if the proper procedure to check TWIP and TWDIS is not followed.