Some real-time clock status bits are read-only but clear when read. If diagnostics poll the register first, the alarm task may see only zero. Check the read side effects before replacing the crystal or changing the alarm setting.
Read-only does not mean a read leaves the state unchanged
Japan-based ABLIC's S-35390A uses an external quartz timebase for its calendar and alarms. In Status Register 1, bits B3 and B2 are the INT1 and INT2 flags in alarm mode. The corresponding flag is set when the programmed alarm time is reached. The device clears it automatically on reading. Read-only means the controller cannot set those fields through an ordinary write; it does not imply that a read leaves device state unchanged. Reading the complete byte can consume a pending event in a field the calling software does not use.
The same register contains the power-on detection flag POC at B0, which the manual also describes as automatically cleared on reading. Its initialization requirements differ from alarm handling. Do not generalize this behavior to the other bits. For example, the low-voltage detector's read and resampling behavior is defined separately. Follow this part's initialization rules after power recovery and record alarm and supply state separately. A successful status read does not mean no event occurred.
Worked example: one extra diagnostic read, one missing alarm
Suppose cold-storage equipment uses alarm 1 for periodic reminders in 24-hour mode. Assume all other status flags are zero. After the alarm, B6 and B3 in Status Register 1 are set, so the status byte is 0x48 using the manual's bit numbering. At 2 ms after the alarm, a diagnostic task reads 0x48 but displays only the clock mode and does not save B3. At 5 ms, the application task may read 0x40. The times, bytes and task scheduling are illustrative, not device response-time specifications.
| Operation | Possible raw status | Interpretation |
|---|---|---|
| First status read | 0x48 | Bitwise AND of 0x48 and mask 0x08 is nonzero: alarm 1 needs handling |
| Later read, with no new alarm | 0x40 | The read cleared B3; this does not negate the first result |
| Application reads the saved first snapshot | The 0x48 record is still available | Distribute one event without reading hardware again |
The reads are 3 ms apart without any change in oscillator frequency. Making them closer does not let the second read see a flag already consumed by the first. Conversely, a saved byte must not be reported as a new alarm each time it is used. Associate the snapshot with a read time and an event number. Let application software record that the alarm was handled according to its own rules. A software event record and the device's current state are different; repeatedly reading the same address does not synchronize them.
Assign one owner for the first read
During normal operation, let the interrupt handling path or a common driver entry point read the original Status Register 1 byte and preserve context. Decode the relevant flags from that byte and notify the alarm, diagnostic and logging modules. A diagnostic page should read the saved snapshot by default, not query the RTC directly. Check startup scans, debug commands and service tools for reads of the same register. They can change what subsequent reads reveal without writing anything.
The datasheet also instructs the host to handle the corresponding alarm mode bit after reading a set alarm flag. Saving the first byte does not remove the later steps in the manual. Keep validation evidence for how the alarm was enabled, what the first read returned, what happened afterward and whether the next alarm was rearmed correctly. If logs are still missing with diagnostics off, compare pin activity with the bus sequence. Distinguish an alarm that never triggered, a flag consumed by another read and an interrupt that did not reach the application. The fixes are different.
Include an explicit contention test. First run the normal handler only. Then reproduce the behavior with the old diagnostics that directly read the status. Finally repeat with the shared software snapshot. Keep the alarm time, reference offset and board settings the same in all three runs. Record the first reader, each raw response and whether the application received the notification. Observe the bus passively with a logic analyzer. An extra read to check whether the flag is set can make the test equipment the first reader.
Review status retention as well as voltage when qualifying a replacement
| Check | Evidence to retain | Mistake it prevents |
|---|---|---|
| Full part and revision | Order information, manual revision and alarm mode | Assuming any two-wire RTC has compatible status behavior |
| First reader | Which driver, task or diagnostic tool reads first | Looking only at the application's second reading |
| Raw evidence and timing | Pin event, bus request, raw result and snapshot sequence number | Confusing a historical event with a zero in current hardware status |
| Follow-up actions | Alarm mode handling, initialization and rearm sequence | Fixing readout without testing the next alarm |
| Replacement | Retention, clearing, alarm source and applicable conditions | Treating read-to-clear, write-to-clear and reset as interchangeable |
If the existing system depends on the flag staying set until the application handles it, change the driver or select a candidate that supports that behavior. The quote request need not list every register, but should identify which flags must remain available across software modules and which are retained by the host. A correct calendar or normal quartz waveform is not a full test of the path from the RTC alarm to the application log.
If the first status byte is placed in a software queue, define how evidence is retained when it fills, the application pauses or the controller resets. A recorder that needs traceability can save the raw byte and sequence before mapping it to an application alarm. A final summary alone cannot show whether the hardware flag was ever set. A snapshot without delivery status cannot show whether the application received it. The existence of a software queue does not imply the RTC can queue multiple unread alarms.
In the final diagnostic interface, distinguish the last saved event from the time its status snapshot was taken. Opening the page should not cause another hardware read. Refreshing it should not present an old alarm as new. If a service mode requires direct reads, define how it pauses the normal handler, preserves the first result and returns to normal operation. Include these steps in system validation so enabling diagnostics does not change the alarm behavior being observed.
Frequently asked questions
A second read returns zero. Can I conclude no alarm happened?
No. Find the first read and the pin activity. If that first read cleared the flag, the second describes only the state when it was read.
If disabling logging restores the alarm, does that show the crystal was faulty?
No. Two tasks competing to read status are a more direct possibility. Check the bus order and first snapshot, then use an independent reference if actual clock accuracy needs verification.
