DavidGriffith / minipro-import-test

An open source program for controlling the MiniPRO TL866xx series of chip programmers
GNU General Public License v3.0
3 stars 0 forks source link

DS1642 can be supported? (RTC Oscillator Calibration) #253

Open DavidGriffith opened 2 years ago

DavidGriffith commented 2 years ago

In GitLab by @rtek1000 on Jan 28, 2022, 12:36

Hello,

I would like to know if this programmer accepts that the pins are controlled through commands and if some kind of script could be used to activate the power supply and the address pins.

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

The M48T02/12 TIMEKEEPER® RAM is a 2 Kb x 8 non-volatile static RAM and real-time clock (RTC) which is pin and functional compatible with the DS1642.

This memory is already supported in the xgpro program list (M48T02 or M48T12), but it doesn't have the calibration part (at least I didn't find any tutorial about it).

I thought of using a logic analyzer to read this 512Hz signal. But I need to feed the memory and set the address, I would like to take advantage of the TL866ii Plus programmer to support this. Another alternative would be to use a breadboard, or a dedicated board, but I'd like to try with the TL866ii Plus first.

I found these conditions to perform the test:

Source: https://www.st.com/resource/en/datasheet/m48t02.pdf

And the calibration must be done with these parameters:

The second approach is better suited for a manufacturing environment, and involves the use of a special test mode (as described in the section entitled, “Enabling the frequency test function (FT)” which derives a 512Hz signal from the clock divider chain, as indicated in Figure 2. This signal can be used to measure the accuracy of the crystal oscillator. The right-hand pair of columns in Table 1 on page 6 provides a look-up table similar to that in the left-hand pair of columns, except that the error values are expressed in “ppm” units instead of seconds per month. The error in ppm can be quickly calculated by dividing the measured error from 512 Hz by 512 and multiplying the result by 1 million. For example, if the frequency measured during the test mode is 511.998 Hz, the delta is –0.002. Dividing by 512 and multiplying by 1 million, the result is –3.906 ppm. In this case, the nearest compensation value is a +4.068. The appropriate sign bit in this case is a logical '1,' indicating the clock needs to speed up to compensate for the lost time. This yields a calibration value of “100001.”

Source: 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

Ref.: https://github.com/beneater/eeprom-programmer/issues/18

Note: I know there is DS3231 (or DS3232) memory that has the oscillator self-compensated, to avoid all this manual calibration work, but unfortunately some old equipment uses these parallel memories.

Thank you.

DavidGriffith commented 2 years ago

In GitLab by @rtek1000 on Jan 28, 2022, 18:02

I managed to test the memory (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:

Address 7F8: 0x80 (WRITE bit: Enables writing of RTC addresses - Set to '0' for normal clock operation)

Address 7FC: 0x40 (FREQUENCY TEST bit - Set to '0' for normal clock operation)

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.

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

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