NEW DATABASE - 350 MILLION DATASHEETS FROM 8500 MANUFACTURERS
DS174 DS164 DS1642 DS1643 DS1644 DS1646 DS1647 DS1742 DS1743 DS1744 DS1746 - Datasheet Archive
Using a Nonvolatile Timekeeping RAM with a Microcontroller www.maxim-ic.com INTRODUCTION The nonvolatile timekeeping family of
Application Note 519 Using a Nonvolatile Timekeeping RAM with a Microcontroller www.maxim-ic.com INTRODUCTION The nonvolatile timekeeping family of real-time clock (RTC) products provide battery-backed NV SRAM as well as time and date. The clock registers are accessed identically to the SRAM. Table 1 shows a list of products in the nonvolatile timekeeping family. The DS174 DS174_ series are identical to the DS164 DS164_, with the addition of a century bit and optional 3.3V operation. Table 1. Nonvolatile Timekeeping Products PART DS1642 DS1642 DS1643 DS1643 DS1644 DS1644 DS1646 DS1646 DS1647 DS1647 DS1742 DS1742 DS1743 DS1743 DS1744 DS1744 DS1746 DS1746 DS1747 DS1747 RAM DENSITY VCC (V) 2k x 8 8k x 8 32k x 8 128k x 8 512k x 8 2k x 8 8k x 8 32k x 8 128k x 8 512k x 8 5 5 5 5 5 3.3 or 5 3.3 or 5 3.3 or 5 3.3 or 5 3.3 or 5 PIN CONFIGURATIONS TOP VIEW A14 A12 A7 A6 A5 A4 A3 A2 A1 A0 DQ0 DQ1 DQ2 GND 1 2 Dallas 3 Semiconductor DS1644 DS1644 4 5 6 7 8 9 10 11 12 28 27 26 25 24 23 22 21 20 19 18 17 16 15 32 31 30 29 28 27 26 25 24 23 22 21 VCC A15 N.C. WE A13 A8 A9 A11 OE A10 CE 13 20 DQ6 DQ1 DQ2 14 19 DQ5 15 18 DQ4 GND DQ4 1 2 Dallas 3 Semiconductor DS1646 DS1646 4 5 6 7 8 9 10 11 12 DQ0 DQ5 13 14 N.C. A16 A14 A12 A7 A6 A5 A4 A3 A2 A1 VCC WE A13 A8 A9 A11 OE A10 CE DQ7 DQ6 16 17 DQ3 A0 DQ3 DIP MODULE DQ7 DIP MODULE In the following example, a DS1644 DS1644 or DS1646 DS1646 is connected to a DS87C320 DS87C320. The DS87C320 DS87C320 high-speed microcontroller is compatible with the industry-standard 8051 architecture. Other NV RAM densities could be supported with appropriate changes to the circuit. For related application notes, please refer to the Quick View data sheets for the DS87C320 DS87C320 and DS1644 DS1644. A reference RTC clock shematic follows the code. 1 of 8 REV: 030703 AN519 AN519: Using a Nonvolatile Timekeeping RAM with a Microcontroller DS1644/DS1646 DS1644/DS1646 CODE /*/ /* DS1644 DS1644.c - Access DS1644/6 DS1644/6, DS1744/6 DS1744/6 using Reference RTC circuit */ /* This program if for example only and is not supported by Dallas */ /* Semiconductor Maxim. */ /*/ #include /* Prototypes for I/O functions */ #include /* Register declarations for DS5000 DS5000 */ #include /* needed to define xdata addresses */ #include /* bit definitions */ /* Defines */ /* Global Variables */ uchar yr, mn, dt, dy, hr, min, sec, day; unsigned int MAXADD; sbit RSTb = P2^7; sbit IRQb = P2^6; sbit AD16 = P1^5; sbit AD17 = P1^6; sbit AD18 = P1^7; /* Function Prototypes */ void writereg(); void init_rtc(); void Disp_Clk_Regs(); void ramread(); void ramwrite(); void toggle_ft(); void init_rtc() /* - set the time and date - */ /* Note: NO error checking is done on the user entries! */ { uchar tmp; printf("\nEnter the year (0-99): "); scanf("%bx", &yr); printf("Enter the month (1-12): "); scanf("%bx", &mn); printf("Enter the date (1-31): "); scanf("%bx", &dt); printf("Enter the day (1-7): "); scanf("%bx", &dy); printf("Enter the hour (1-23): "); scanf("%bx", &hr); printf("Enter the minute (0-59): "); scanf("%bx", &min); printf("Enter the second (0-59): "); scanf("%bx", &sec); AD16 = AD17 = XBYTE[0xfff8] XBYTE[0xfff9] XBYTE[0xfffa] XBYTE[0xfffb] XBYTE[0xfffc] XBYTE[0xfffd] XBYTE[0xfffe] XBYTE[0xffff] AD18 = 1; = 0x80; /* set write bit for write */ = sec; = min; = hr; = dy; = dt; = mn; = yr; 2 of 8 AN519 AN519: Using a Nonvolatile Timekeeping RAM with a Microcontroller XBYTE[0xfff8] = 0; /* clear write bit to allow update */ } void Disp_Clk_Regs() /* - */ { uchar msec, Sec, prv_sec = 99, Min, Hrs, Dte, Mon, Day, Yr; AD16 = AD17 = AD18 = 1; printf("\nYr Mn Dt Dy Hr:Mn:Sec"); while(!RI) /* Read & Display Clock Registers */ { XBYTE[0xfff8] = 0x40; /* set read bit to stop updates */ Sec = XBYTE[0xfff9]; Min = XBYTE[0xfffa]; Hrs = XBYTE[0xfffb]; Day = XBYTE[0xfffc]; Dte = XBYTE[0xfffd]; Mon = XBYTE[0xfffe]; Yr = XBYTE[0xffff]; XBYTE[0xfff8] = 0; /* clear read bit to resume updates */ delay(3); /* must allow time for transfer to occur */ if(Sec != prv_sec) /* display every time seconds change */ { printf("\n%02.bX %02.bX %02.bX %02.bX", Yr, Mon, Dte, Day); printf(" %02.bX:%02.bX:%02.bX", Hrs, Min, Sec); } prv_sec = Sec; } RI = 0; } void ramread() { unsigned int j; /* Swallow keypress to exit loop */ /* - Read RAM - */ AD16 = AD17 = AD18 = 0; for (j = 0; j