This clock module rolls its event count back to zero after 63. Whether two samples give the exact increment depends on the sampling window and any resets.
The Epson RX8901CE integrates a quartz crystal, timekeeping and event detection in one real-time clock module. The EVIN event-count field is six bits. Epson specifies a range of 0 to 63; the counter then rolls to zero and continues rather than saturating at 63. A lower second reading could be a normal wrap, a firmware clear or reinitialization. Start with the measurement interval and the configuration history rather than interpreting a smaller number as a loss of events.
1. The register is not a lifetime event total
The counter records input events recognized by the module under its conditions. A qualifying event is not simply any physical edge: input enable, edge settings and front-end signal behavior affect what can count. Epson also states that the counter does not operate when its EVINnEN bit is zero. Two polled values must therefore be traceable to the same channel, the same configuration and a period without resets.
Six bits represent only 64 states. The register can help establish how many events occurred in a bounded interval, but it is not a lifetime count that never moves backward. If the host accumulates a wider total, keep the time, channel and validity for each pair of readings. Set a fresh baseline after reinitialization rather than subtracting an old value across an unknown state.
Do not conflate event count, timestamp entries and buffer status. A zero after wrap does not mean all timestamps were read or show whether an entry was overwritten. A timestamp in the log likewise does not reveal how many events the counter saw between samples. If every individual event must be traceable, inspect the buffer policy and loss conditions separately. For a total, then handle the six-bit boundary.
2. Resolve two unknowns before using modulo 64
Let A be the earlier reading and B the later one. Compute the remainder of (B − A + 64) divided by 64, whether or not B is smaller. This gives the remainder between two states. It is the exact increase only if there is independent evidence that the window contained at most 63 recognized events, the counter was not reset and the channel stayed enabled. The register values do not prove those conditions.
| Item to verify | Evidence to retain | Common misinterpretation |
|---|---|---|
| Valid count bits | Six-bit readings for the same EVIN channel | Treating 63 as saturation |
| Sampling window | Actual timestamps and an independently supported input bound | Using the scheduled polling interval instead of elapsed time |
| Clearing history | Initialization and commands with count clearing enabled | Treating every reduction as a normal wrap |
| Timestamp path | Buffer mode, overwrites and host archive | Equating occurrence count and retained entries |
The first unknown is elapsed time. Host sleep, a busy bus or a failed read can make the real interval longer than planned. Use timestamps for successful samples. The second is intervening state changes, such as disabling an input or executing a command configured to clear the counter. Values from either side of a clear do not belong to one continuous interval. Keep command and sampling events on a common time axis if the driver handles several functions.
3. Worked example: what happened between 61 and 4?
Suppose two successful reads yield 61 and 4. The remainder of (4 − 61 + 64) divided by 64 is 7. If an external reference or a validated input-rate bound limits that window to 63 events, and resets are ruled out, record an increase of 7. Counting through 62, 63 and 0 to 4 gives the same result. The event and timing assumptions illustrate the arithmetic; they are not Epson input-rate guarantees.
If the host sleeps and misses a poll, the same readings could also represent 71 or 135 events: remainder 7 plus one or two complete wraps. If an entire wrap cannot be excluded, do not treat 7 as exact. Two readings of zero are equally ambiguous: there may be no new event, exactly one full wrap, or initialization in between. Display an unknown increment instead of inserting zero just to keep a chart continuous.
An independent input record helps exercise the boundaries. On a validation board, use a verified stimulus and a pulse pattern valid for the board configuration. Capture raw input, host reads and configuration operations on one timebase. Test a no-wrap interval first, then one wrap, then a deliberately delayed software read so the driver must report an uncertain interval. Do not clear records on a field unit first when they might be needed for evidence.
4. Put the sampling assumptions in the acceptance test
Engineering should first define the largest possible event count in a real sampling window. An average rate does not bound bursts; contact bounce, clustered operations and activity after wake can concentrate input. Use a supported worst-case bound to set the maximum sampling interval and leave room for retries. Define behavior after power loss, read failure, configuration lock and software restart separately. If assumptions fail, preserve both raw values and timestamps for later review.
For a return request describing a sudden reduction in the count, purchasing should obtain the full part number, firmware version, input trace, register readings and any reset commands. Epson documents that an applicable command clears the event counters when WRCMD_CFG.EVCNTCLREN is enabled. This is a separate explanation from natural wrap. If the application retained only the final value, report the missing evidence rather than concluding that counting stopped.
Replacement selection also needs a semantics comparison. An RTC module with the same reference frequency, package and interfaces need not share counter width, wrap or clear behavior. Distinguish short-window counting from guaranteed continuous history. A wider counter still needs validation of software sampling, retention and buffer overwrite. First-article tests should check both known increments and the indication for an unknown window, not just require a continuously increasing number on a screen.
Store the software total separately from the raw readings. A legal value after a communications failure cannot reconstruct the interval that was missed unless an independent record supplies the missing evidence. Establish a fresh baseline at recovery and state which interval was excluded. For reporting by shift, provide a confirmed subtotal and list the unknown intervals rather than combining them into one seemingly exact number. Service staff can then check power, the bus and application events in the missing window instead of attributing every discrepancy to the part.
5. Quick questions
If two readings match, can I safely record zero new events?
Only if a clear is ruled out, the same channel remained enabled, and 64 or more events could not have occurred in that window. Otherwise preserve the readings and mark the increment unknown.
Does clearing after every read eliminate the wrap problem?
It does not remove the need for a bound. Events can occur between reading and clearing, and a clear must follow the device’s documented behavior and the application’s timing. For continuous records, separately test what events, if any, the strategy can leave out.
