beneater / eeprom-programmer

Arduino EEPROM programmer
681 stars 190 forks source link

DS1642 can be supported? #18

Open rtek1000 opened 2 years ago

rtek1000 commented 2 years ago

Hello,

Can NV RAM with built-in RTC model DS1642 be supported by this programmer?

As I understand it, this is an NV RAM that has RTC built in, but the operation is similar to a regular parallel NV RAM.

Parallel EEPROM memory has similar read and write commands.

Datasheet: https://datasheets.maximintegrated.com/en/ds/DS1642.pdf

Thank you.

rtek1000 commented 2 years ago

In case anyone needs such a memory, I found this other compatible code: M48T02/12:

https://www.st.com/en/clocks-and-timers/m48t12.html

Description The M48T02/12 TIMEKEEPER®RAM is a 2 Kb x 8 non-volatile static RAM and real-time clock which is pin and functional compatible with the DS1642. A special 24-pin, 600 mil DIP CAPHAT™package houses the M48T02/12 silicon with a quartz crystal and a long life lithium button cell to form a highly integrated battery-backed memory and real-time clock solution. The M48T02/12 button cell has sufficient capacity and storage life to maintain data and clock functionality for an accumulated time period of at least 10 years in the absence of power over the operating temperature range. The M48T02/12 is a non-volatile pin and function equivalent to any JEDEC standard 2 Kb x 8 SRAM. It also easily fits into many ROM, EPROM, and EEPROM sockets, providing the non-volatility of PROMs without any requirement for special WRITE timing or limitations on the number of WRITEs that can be performed.

rtek1000 commented 2 years ago

This datasheet is more complete: https://www.st.com/resource/en/datasheet/m48t02.pdf

This DS1642 memory can be read and written by TL866II Plus programmer, just select M48T12 memory (I asked developer to add DS1642 too, new xgpro software version released, not tested yet).

It is necessary to operate the write bit of the DS1642 to be able to write the clock addresses.

3.2 Setting the clock The eighth bit of the control register is the WRITE bit. Setting the WRITE bit to a '1,' like the READ bit, halts updates to the TIMEKEEPER registers. The user can then load them with the correct day, date, and time data in 24-hour BCD format (on Table 5 on page 13). Resetting the WRITE bit to a '0' then transfers the values of all time registers (7F9-7FF) to the actual TIMEKEEPER counters and allows normal operation to resume. The FT bit and the bits marked as '0' in Table 5 on page 13 must be written to '0' to allow for normal TIMEKEEPER and RAM operation.

The DS1642 (or M48T02 or M48T12) has an internal oscillator that can be calibrated, so a 512Hz frequency measurement service is required (D0 pin).

(3.4 Calibrating the clock) ...When the Frequency Test (FT) bit, the seventh-most significant bit in the day register, is set to a '1,' and the oscillator is running at 32,768 Hz, the LSB (DQ0) of the seconds register will toggle at 512 Hz...

It also has a read bit, which helps to prevent the read from being done when updating the clock addresses.

3 Clock operations 3.1 Reading the clock Updates to the TIMEKEEPER® registers should be halted before clock data is read to prevent reading data in transition. The BiPORT™ TIMEKEEPER cells in the RAM array are only data registers and not the actual clock counters, so updating the registers can be halted without disturbing the clock itself. Updating is halted when a '1' is written to the READ bit, the seventh bit in the control register. As long as a '1' remains in that position, updating is halted. After a halt is issued, the registers reflect the count; that is, the day, date, and the time that were current at the moment the halt command was issued. All of the TIMEKEEPER registers are updated simultaneously. A halt will not interrupt an update in progress. Updating is within a second after the bit is reset to a '0.'

These details are all in the datasheet of M48T02/12.

rtek1000 commented 2 years ago

For more information on calibration, see the application note AN924, “TIMEKEEPER® calibration.”

https://www.st.com/resource/en/application_note/an934-how-to-use-the-digital-calibration-feature-in-timekeeper-and-serial--realtime-clock-rtc-products-stmicroelectronics.pdf

rtek1000 commented 2 years ago

I found a library that seems to have good accuracy for measuring low frequencies using Arduino, maybe this library can be used to calibrate in a basic way at least:

https://github.com/PaulStoffregen/FreqMeasure/issues/22

rtek1000 commented 2 years ago

I managed to test the memory, using logic analyzer (but the calibration must need more precision equipment, the reading was fluctuating in the thousandths of a Hz, 24MHz sampling).

Need to write these addresses before testing:

I needed to leave the address and control pins with this configuration in the image below, in case anyone wants to test it someday. (VCC: +5V; VSS: GND or 0V)

FT

It is important to be aware of this (strange) information that is in the datasheet:

Unfortunately I came to the conclusion that the Saleae Logic software (with 8-channel logical analyzer) seems to be better than the Sigrok software (with 16-channel logical analyzer). Both analyzers with CY7C68013A I.C., the difference is that the 8-channel analyzer has a buffer, but I don't know if this can affect the reading that much.

8 ch type: https://atadiat.com/en/e-hands-on-test-saleae-usb-logic-analyzer-24mhz-8ch-clone/

16 ch type: https://forum.hobbycomponents.com/viewtopic.php?t=1891