Skip to content

RTC save writes the weekday in binary; the RX8130CE's WEEK register is one-hot #39

Closed

Description

@ptr727

zephcore_rtc_save() writes the day of the week as a binary 0-6 (0 = Sunday) into whichever time-block byte the date does not use. That suits the DS3231, PCF8563 and RV3028. It is wrong for the RX8130CE, whose WEEK register (13h) is one-hot.

The manual: Epson RX8130CE Application Manual ETM50E-10, §14.1.2 "Week counter", Table 15, p. 27: "The day (of the week) is indicated by 7 bits, bit 0 to bit 6", Sunday 01h, Monday 02h … Saturday 40h, and "Do not set '1' to more than one day at the same time."

What ZephCore writes:

Day Should be ZephCore writes
Sunday 01h 00h: no day
Monday 02h 01h: Sunday
Wednesday 08h 03h: two days at once
Saturday 40h 06h: two days at once

The time and date are unaffected, since ZephCore never reads the weekday back, but the chip's week counter holds an invalid value after every sync. It matters only to whatever reads it, such as a weekday alarm or another firmware.

Affected boards: any that include rtc-i2c.dtsi with an RX8130CE fitted at 0x32. meshtracker_x1's own 0x32 descriptor (RX8900 layout) needs the same check against that part's data sheet.

Fix direction: a per-descriptor property for the weekday encoding (binary or one-hot), set on the RX8130CE descriptor, with the save writing 1 << dow for one-hot.

Found by the local review of #38. Not fixed there, being pre-existing and outside its scope.

Activity

  1. ptr727 commented on Oct 4, 2026

    @ptr727
    OwnerAuthor

    MeshCore has the same defect: RTC_RX8130CE::setTime() in src/helpers/RTC_RX8130CE.cpp writes bin2bcd(t->tm_wday) & 0x07 to 13h, and getTime() reads it back the same way (checked at ptr727/meshcore-dev-MeshCore dev 3e3150c, which includes the latest upstream merge). Passed to the MeshCore session to decide its upstream handling.

  2. ptr727 commented on Oct 4, 2026

    @ptr727
    OwnerAuthor

    MeshCore's fix for the same defect is upstream: meshcore-dev/MeshCore#3550 (issue meshcore-dev/MeshCore#3549), writing 1 << tm_wday and decoding the lowest set bit. ZephCore's fix should follow the same encoding.

  3. ptr727 commented on Oct 5, 2026

    @ptr727
    OwnerAuthor

    A lead on the open meshtracker_x1 part, from the local review of #45 after dev (liquidraver#98) was merged in. Not proven.

    • The suspected gap. meshtracker_x1's rtc-ysn8900@32 node uses the RX8900 register layout, and its weekday is still written as 0-6.
    • The evidence so far. Linux drives epson,rx8900 through rtc-rv8803.c, which writes the weekday as 1 << tm_wday. If the YSN8900 follows the RX8900 there, this board has the same wrong-day defect as the RX8130CE, and the fix is to add weekday-one-hot; to that node.
    • What's missing. No RX8900 or YSN8900 data sheet is available here. The upstream PR for rtc: write the RX8130CE weekday one-hot #45 leaves this board unchanged until one confirms the encoding.
  4. ptr727 commented on Oct 5, 2026

    @ptr727
    OwnerAuthor

    Resolved for meshtracker_x1. The Epson RX8900 Application Manual (ETM45E-11, §8.2.2, Table 15, p. 16) gives WEEK (03h) as one-hot, Sunday 01h to Saturday 40h. The YSN8900 brief has no register map, but its pinout matches the RX8900CE pin for pin, and the board already uses the RX8900 map. With Pieter's approval, weekday-one-hot is now set on the rtc-ysn8900@32 node and folded into liquidraver#101 (head 2621782). The YSN8900 programming guide is still unavailable, so this rests on it being an RX8900 second source. MeshCore is unaffected: its meshtracker_x1 never drives the chip.

  5. ptr727 commented on Oct 10, 2026

    @ptr727
    OwnerAuthor

    Fixed upstream by liquidraver#101, merged 2026-10-06: the RX8130CE and YSN8900 weekday is written one-hot.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions