0 Real‐Time Clock
Ancyker edited this page 2023-08-01 22:09:21 -04:00

The optional real-time clock (RTC) will allow the OSCR to timestamp the files and folders it creates. This is especially useful for anyone that dumps ROMs and/or saves a lot and has trouble keeping track of when they dumped something. Additional features using the RTC are technically possible but none are planned.

Does everybody know what time it is?

The battery-backed RTC uses a CR1616 battery. To avoid unnecessarily draining the battery the RTC IC pulls power directly from the USB port (VBUS) before the power switch. This means that if you leave the OSCR plugged in but powered off, the clock will continue to keep time using the power from the USB port rather than the battery. The intent of this is to save the battery as a battery is almost always more expensive than wherever the USB power is coming from, especially since it isn't rechargeable.

Note: At the time of this writing (2023-07-18), the standard frame used for HW5 is incompatible with the RTC battery retainer. See #827 for details.

SMT Components / Soldering Difficulty

Installation of the RTC is moderately difficult. While all of the RTC components are SMD, the hardest-to-install component is the capacitor as it is an SMT 0402 component. See the Automatic Voltage Selection page for information about SMT components and the difficulty of installing 0402 components.

Preassembled Options

If you live in the USA, you can purchase a preassembled PCB kit with the RTC (and optionally automatic voltage selection) already installed here for ~$32 shipped (~$42 with auto voltage). Other sellers may be offering this service as well. Check the What to order page for a list of sellers.

Installation Options

The RTC installation described on this page requires at least HW5 Revision 5. It is not practical to install the RTC on prior revisions. (And while it is technically possible to add it with bodge wires, if you were someone with the technical skill to do that, you probably wouldn't be reading this guide other than maybe to grab the part numbers.)

Components

The components list is short, requiring only three (plus a CR1616 battery, of course).

Component Locations

  • U2: DS3231MZ
  • C5: 0.1uF Capacitor
  • BT1 ("RTC BATTERY"): Battery Retainer

image

Installation

If you are hand soldering, start by soldering the capacitor (C5) first. If you are installing Vselect, do those capacitors and the resistor as well and install U1 (Vselect) before moving on to the RTC. After that, solder the RTC IC (U2). If you are using hot air or a hot plate, you should solder all of these at the same time.

Important: Pin one of the RTC IC goes in the top left, next to the silkscreen "U2" with the line that extends over the pad. Pin 1 of the IC is marked on the IC itself with a "+" symbol and can be difficult to see. Ensure proper orientation before soldering!

After soldering those, assemble the rest of the main board as per the instructions. After soldering all the other components and headers to the main board, install BT1 (the battery retainer) on the back of the board. First, add some solder to the center ground pad. You don't need a lot, you just need enough to raise the pad above the surface of the board so that the battery's negative side is pressed against the board.

Finally, solder the retainer onto the board. The footprint's silkscreen as well as most frames/cases/enclosures assume you will insert the battery from the inside of the OSCR. However, if you are making your own case or using someone else's case, it's fine to rotate the holder 180 degrees if it is required for your/their design. This is because both the left and right terminals are positive.

After soldering down the RTC bracket continue assembling the OSCR as normal. Install the battery when it is most convenient to do so (likely after fully assembling the OSCR). When flashing the firmware make sure to uncomment the "RTC_installed" line in the config to enable RTC support.

Setting The Time

When you first flash the firmware to the OSCR it will use the build time of the firmware image to set the time. In most cases this results in the time being off by as much as a few minutes. In addition, the FAT32 file system does not support timezones. Windows expects the times to be the local system timezone while Linux expects it to be UTC. This can result in the time being very off if mixing systems or using Linux.

Before you can set the time you will need to enable the firmware updater. To do this, uncomment the "ENABLE_UPDATER" line in the config and flash the firmware. You can confirm this worked by looking at the console log in the Arduino IDE. When the OSCR is first connected/powered on it will immediately send its hardware version, firmware version, and enabled features over serial. You can verify this further by typing VERCHK into the input and pressing enter to get this information.

To check the current time you can use the command GETTIME which will cause the OSCR to send the current date/time over serial. To set the time, you will need to know the time value as a UNIX epoch/offset. You can use an online tool to help you with that. Make sure the timezone is set to UTC unless you are on Linux and entering a local time. Pad it by a few seconds to give you time to type the command. The command is SETTIME <timestamp>, such as SETTIME 1689468590. This will immediately set the time and return the resulting human-readable date and time. You can do this a few times until the clock is as accurate as you need it.

Congratulations on your RTC!