TECHNICAL DATA CMOS IC OF REAL TIME WATCH WITH SERIAL INTERFACE, 64 Х 8 RAM IN1307 FUNCTIONS AND FEATURES Count of seconds, minutes, hours, week days, date, months and years with consideration of the leap years (before 2100); 56 bytes of the power self-sufficient RAM for the data storage; SOP-8 Two-wire consecutive interface; Programmable rectangular output signal; Automatic determination of the supply voltage drop and the switching diagram; DIP-8 Consumption of less than 500 nА in the back-up supply mode with the operating generator; TA = -40 to+ 85C for all packages Temperature range of the industrial application: -40С – 85С Accuracy is better than ±1 minute per month Ordering Information Device IN1307N IN1307DT IN1307D Operating Temperature Range Package Packing TA = -40°C ~+85°C for all packages DIP-8 SOP-8 SOP-8 Tube Tape& Reel Tube DESCRIPTION IN1307 is essentially the binary – decimal digital watch with a calendar, it has the additional 56 bytes of the power self-sufficient static RAM and possesses the low power consumption. The addresses and data are applied consecutively via the two-wire bi-directional bus. The microcircuit is intended for count of the real time in hours, minutes and seconds, count of week days, date, month and year. The last day of the month is automatically adjusted for the months of less, than 31 days, including correction for the leap year. The watches function in the 24-hour format or in the 12-hour format with the AM / PM-indicator. IN1307 has the built-in power supply control circuit, which determines the supply disruption and automatically switches over the device into the battery mode. PIN DISCRIPTION Pin Symbol I/O 1 2 3 4 5 6 7 8 X1 X2 VBAT GND SDA SCL SQW/OUT VCC In In In In Bi In Out In Pin Description Pin for connection of the quartz resonator Pin for connection of the quartz resonator Pin for battery Ground pin Input / output of serial data Input of the consecutive cycle signal Output of rectangular signal Power supply pin 2013, December, Ver.04 IN1307 BLOCK DIAGRAM X1 X2 Generator & Divider SQW/OUT Pulse Former VCC VBAT GND Supply Control RTC Control Circuits SCL RAM (56 X 8) Address Register Interface BUS SDA OPERATING TEMPERATURES RANGE Operating temperatures range of the microcircuit IN1307: ТА = - 40 ... + 85 С. RECOMMENDED DC OPERATING CONDITION and ABSOLUTE MAXIMUM RATING Parameter Symbol Recommended Operating Condition Absolute Maximum Rating Supply voltage VСС min 4.5 max 5.5 min -0.5 max 7.0 Battery voltage VBAT 2.0 3.5 -0.5 7.0 Low level input voltage VIL -0.3 0.8 -0.5 7.0 High level input voltage VIH 2.2 VCC+ 0.3 -0.5 7.0 Storage temperature TS - - -55 +125 Unit V V V V С * Stresses beyond those listed under “absolute maximum ratings” may cause permanent damage to the device. These are stress ratings only and functional operation of the device at these or any other conditions beyond those indicated under “recommended operating conditions” is not implied. Exposure to absolute-maximum-rated conditions for extended periods may affect device reliability. 2 2013, December, Ver.04 IN1307 DC ELECTRICAL CHARACTERISTICS (ТА = –40...+ 85С, VCC = 4.5 – 5.5 V ) – Limit min – max 1 – – 1 uА VOL VСС = 4.5 V – 0.4 V ICCA fSCL = 100 kHz – 1500 µА ICCS VСС = 5 V and SDA, SCL = 5 V – 200 µА IBAT1 VCC = 0 V, VBAT = 3 V – 0.5 µA IBAT2 VCC = 0 V, VBAT = 3 V – 0.8 µA Parameter Symbol Mode Input leakage current, (SCL only) In / Out leakage current, (SDA and SQW/OUT) Low level output voltage Consumption current in the data transfer mode Consumption current in the static mode Consumption current in the battery mode (SQW/OUT OFF., 32 kHz – ON) Consumption current in the battery mode (SQW/OUT – ON, 32 kHz – ON) ILI ILO 1) Unit uА Low level voltage is determined under the load current of 5 mА; VOL = GND under the capacitance load AC ELECTRICAL CHARACTERISTICS (ТА = –40...+ 85С, VCC = 4.5 – 5.5 V ) Parameter Cycle frequency SCL Symbol – fSCL Limit Mode Min Max 0 100 4.7 – 4.0 – Unit kHz Time of the bus vacant status between the tBUF statuses of STOP and START 1) tHD:STA Hold time (repeated) of START status – Duration of the low status of the cycle pulse SCL tLOW – 4.7 – Duration of the cycle pulse high status SCL tHIGH – 4.0 – tSU:STA – 4.7 – µs – – – – – – – – 0 250 – – 4.7 – 10 12.5 – – 1000 300 – 400 10 12.5 µs ns ns ns us pF pF pF Pre-set time for the repeated status START Data hold time Data pre-set time Rise time of signals SDA and SCL Drop time of signals SDA and SCL Pre-set time for the status STOP TotaL capacitance load per each bus line IN / OUT capacitance Load capacitance of the quartz resonator tHD:DAT tSU:DAT tR tF tSU:STO CB CI/O СLX – 2) µs µs µs µs After this time interval the first time cycle signal is formed; Device should internally ensure the hold time, at least, 300 nsec for the signal SDA (relative to V IHMIN of signal SCL) in order to overlap the indeterminancy area of the fall signal of SCL. maximum value tHD:DAT should be definite in that case, if the device does not increase duration of the low status (tLOW) of signal SCL. 3 2013, December, Ver.04 IN1307 TYPICAL OPERATION CHARACTERISTICS (Vcc=5.0V, TA= +25C, unless otherwise noted) 4 2013, December, Ver.04 IN1307 TIMING CHART FUNCTIONING IN1307 operates as the driven device on the serial bus. For access to it it is required to set the status START and to send after the register address the device identification code. It is possible to address the next register consequently, until the status STOP is set. When VCC drops below 1.25 x VBAT, the access in progress to the device is ceased and the address counter is reset. At this time the device does not recognize the input data, excluding the erroneous information writing. When VCC drops below VBAT, the device switches over to the battery mode, consuming low power. When switching on the power supply VCC above VBAT + 0.2 V, the device switches over from the battery power supply to VCC; and recognizes the input data, when VCC becomes above 1.25 x VBAT. ADDRESSES CHART OF RTC AND RAM Addresses chart of the registers RTC and RAM is indicated in the Figure. Hour registers of the real time are positioned at the addresses 00h – 07h. RAM registers are positioned at the addresses of 08h – 3Fh. In the mode of the multi-byte access, when reaching by the pointer of the address 3Fh, the end of the RAM address space, there happens transition to the register with the address 00h, beginning of the hours area. 5 2013, December, Ver.04 IN1307 OSCILLATOR CIRCUIT IN1307 uses an external 32.768kHz crystal. The oscillator circuit does not require any external resistors or capacitors to operate. Table specifies several crystal parameters for the external crystal. CRYSTAL SPECIFICATIONS* Parameter Nominal Frequency Symbol Min fo Series Resistance ESR Load Capacitance CL Typ Max 32.768 kHz 45 12.5 Unit k pF *The crystal, traces, and crystal input pins should be isolated from RF generating signals. Application Note : Crystal Considerations for Real-Time Clocks for additional specifications. See 12 page. CLOCK ACCURACY The accuracy of the clock is dependent upon the accuracy of the crystal and the accuracy of the match between the capacitive load of the oscillator circuit and the capacitive load for which the crystal was trimmed. Additional error will be added by crystal frequency drift caused by temperature shifts. Externalcircuit noise coupled into the oscillator. OSCILLATOR CIRCUIT SHOWING INTERNAL BIAS NETWORK . Figure shows a functional schematic of the oscillator circuit. If using a crystal with the specified characteristics, the startup time is usually less than one second. 6 2013, December, Ver.04 IN1307 RECOMMENDED LAYOUT FOR CRYSTAL HOURS AND CALENDAR Information on the time and date is obtained by means of reading the appropriate register bytes. Hour registers of the real time are indicated in the Figure. Pre-setting and time and calendar initialization are performed by means of writing the appropriate bytes. Information, contained in the time and calendar registers, represents the binary-decimal code. Bit 7 of register 0 represents the hour stop bit (CH). When this bit is set to “1” , the generator is off. When switching on the power supply, the initial status of all registers is not determined. It is necessary to enable the generator (bit CH = 0) when setting the initial configurations. IN1307 operates in the 12-hour or in the 24-hour format. The bit 6 of the watch register determines the operational mode. 12-hour mode corresponds to the high level. In the 12-hour mode the bit 5 is the AM/PM bit. The high level corresponds to PM. In the 24-hour mode, the 5 is the second bit of tens of hours (20 -23 hours). During application of the signal “START” to the two-wire bus there happens transfer of the real time to the auxiliary set of registers. The time data are read from these auxiliary registers, while the watch proceeds in operation. This eliminates the necessity of repeated reading in case of updating the basic registers in the access process. REGISTERS RTC IN1307 7 2013, December, Ver.04 IN1307 CONTROL REGISTER Control register is used for control of pin SQW/OUT. BIT 7 BIT 6 BIT 5 BIT 4 BIT 3 BIT 2 BIT 1 BIT 0 OUT X X SQWE X X RS1 RS0 OUT (output control): This bit presets the output logic level of the pin SQW/OUT, when the output of the rectangular signal is locked. SQWE (rectangular signal enabling): This bit, pre-set to the logic “1”, activates the generator output. Frequency of the output rectangular signal is determined by the bits RS0 and RS1. RS (frequency selection): These bits determine the frequency of the output rectangular signal, when the output of the rectangular signal is activated. The table indicates the frequencies, which can be selected by the bits RS. RS1 RS0 Frequency SQW/OUT 0 0 1 Hz 0 1 4,096 kHz 1 0 8,192 kHz 1 1 32,768 кГц 8 2013, December, Ver.04 IN1307 TWO-WIRE SERIAL DATA BUS IN1307 supports the bi-directional two-wire bus and the protocol of the data exchange. The bus can be controlled by the “master” device, which generates the cycle signal (SCL), controls access to the bus, generates the statuses START and STOP. Typical configuration of the bus with the two-wire protocol is indicated in Figure. Data transfer can be initiated only when the bus is not occupied. In the process of the data transfer the data line should remain stable, while the line of the cycle signal is in the high status. Status alterations of the data line at that moment, when the cycle line is in the high status, will be regarded as the control signals. In compliance with this the following conditions are determined: Bus not occupied: both the data line and the cycle signal are in the HIGH status. Data transfer start: Status alteration of the data line during transition from HIGH to LOW, while the cycle line is in the HIGH status, is determined as the status START. Data transfer stop: Status alteration of the data line during transition from LOW to HIGH, while the cycle line is in the HIGH status, is determined as the status STOP. Valid data: Data line status complies with the valid data, when after the status START the data line is stable during the HIGH status of the cycle signal. Data on the line should be altered at the time of the LOW status of the cycle signal. One cycle pulse per one data bit. Each data transfer starts at the beginning of the status START and ceases at the beginning of the status STOP. Number of the data bytes, transferred between the statuses START and STOP is not limited and is determined by the «master» device. Information is transferred byte by byte, and each receipt is confirmed by the ninth byte. IN1307 operates in the normal mode only (100 kHz). Confirmation of receipt: Each receiving device, when it being addressed, has to generate the recept confirmation after receiving each byte. «Master» device should generate the cycle pulses, which are allocated in compliance with the confirmation bits. If the receipt confirmation signal is in the high status, then on arrival of the confirmation cycle pulse, the device, confirming the receipt, should switch over the SDA line to the low status. Of course, there should be considered the pre-set time and the hold time. The «master» device should signalize on completion of the data transfer to the “slave” device, ceasing generation of the confirmation bit on receiving the receipt confirmation from the “slave” cycle pulse. In this case, the «slave one should switch over the data line to the low status, in order to enable the «master» one generate the condition of STOP. 9 2013, December, Ver.04 IN1307 DATA TRANSFER BY THE SERIAL TWO-WIRE BUS Depending on the status of bit R / W , there are possible two types of transfer: 1. Data are transferred from the «master» transmitter to the «slave» receiver. The first byte, transmitted by the «master» one, is the address for the «slave» one. Then follows a sequence of the data bytes. The «slave» one returns the receipt confirmation bytes after each received byte. Order of the data transfer: the first is the most senior digit (MSB). 2. The data are transferred from the «slave» transmitter to the «master» receiver. The first byte (address of «slave») is applied to the «master». Then the «master» returns the confirmation bit. This follows after the transfer by the «slave» of the data sequence. The «master» returns the receipt confirmation bit after each received byte, with the exception of the last byte. After receipt of the last byte the receipt confirmation bit is not returned. The «master» device generates all cycle pulses and the statuses START and STOP. Transfer is completed at emergence of the status STOP or the repeated emergence of the status START. As the repeated status START is the beginning of the next serial transfer, the bus is not vacated.The data transfer order: the first is the most senior digit (MSB). 10 2013, December, Ver.04 IN1307 IN1307 CAN OPERATE IN THE TWO FOLLOWING MODES 1. Mode of «slave» receiver (write mode of IN1307): Serial data and cycles are received via SDA and SCL appropriately. After transfer of each byte the confirmation bit is sent. The statuses START and STOP are recognized as the beginning and the end of the serial transfer. The address recognition is performed by means of the hardware after receipt of the “slave” address and the direction bit. The address byte isthe first byte, received after occurrence of the START status, generated by the “master”. The address byte contains the seven address bits of IN1307, equal to 1101000, accompanied by the direction bit ( R / W ), which for write is equal to 0.After receipt and decoding of the address byte, DS1307 applies confirmation to the line SDA. After confirmation by IN1307 of the “slave” address and the write bit, the «master» sends the register address of IN1307. Thus the register indicator will be preset in IN1307. Then the «smart» shall start to send each data byte with the subsequent receipt confirmation of each byte. Upon completion of writing the “master” shall formulate the status STOP for termination of the data transfer. <Slave Address> ss 1101000 1101000 <R/W> Data Writing- Mode of << SLAVE>> Receiver <Word Address (n)> 00 AA XXXXXXX XXXXXXX S - START A - ACKNOWLEDGE P - STOP *R/W - READ/WRITE OR DIRECTION BIT <Data (n)> <Data (n+1)> <Data (n+X)> AA XXXXXXXX XXXXXXXX AA XXXXXXXX XXXXXXXX AA XXXXXXXX XXXXXXXX AA PP DATA TRANSFERRED ( X+1 BYTES + ACKNOWLEDGE) ADDRESS = D0h Data Writing- mode of << SLAVE>> Receiver 11 2013, December, Ver.04 IN1307 2. Mode of «slave» Tranceiver (read-out mode from IN1307): The first byte is received and processed as in the mode of the «slave» receiver. However, in this mode the direction bit will signify, that the transmission direction is changed. IN1307 sends the serial data by SDA, the cycle pulses - by SCL. statuses START and STOP are understood as the beginning and end of the consecutive transmission. The address byte is the first byte, received after occurrence of the status START, generated by the «master». The address byte contains the seven bits of the address IN1307, equal to 1101000, accompanied by the direction bit ( R / W ), which is equal to 1 for reading. After receipt and decoding of the address byte IN1307 receives confirmation from the line SDA. Then IN1307 starts to send the data from the address, which is indicated by the register indicator. If the register indicator is not written prior to initialization of the read mode, then the first read address is the last address , retained in the register indicator. IN1307 should send the bit of «non-confirmation», in order to complete the reading. Data Reading – Mode of << SLAVE>> Transmitter acknowledgement from slave S 0 A SLAVE_ADDRESS acknowledgement from slave WORD_ADDRESS A S acknowledgement from slave SLAVE_ADDRESS 1 A acknowledgement from master A DATA n byte R/W at this moment mastertransmitter becomes master receiver and IN1363 slave-receiver becomes slave-transmitter R/W auto increment memory word address no acknowledgement from master DATA 1 P last byte auto increment memory word address <Slave Address> <R/W> Master reads after setting word address (write word address ; read data ) <Data (n)> ss 11 AA XXXXXXX XXXXXXX 1101000 1101000 S A P A - START - ACKNOWLEDGE - STOP - NOT ACKNOWLEDGE *R/W - READ/WRITE OR DIRECTION BIT <Data (n+1)> <Data (n+2)> <Data (n+X)> AA XXXXXXXX XXXXXXXX AA XXXXXXXX XXXXXXXX AA XXXXXXXX XXXXXXXX AA PP DATA TRANSFERRED ( X+1 BYTES + ACKNOWLEDGE) : LAST DATA BYTE IS FOLLOWED BY A NOT ACKNOWLEDGE( A ) SIGNAL ADDRESS = D1h Data reading – mode of «slave» transmitter 12 2013, December, Ver.04 IN1307 APPLICATION NOTE CRYSTAL CONSIDERATIONS WITH REAL-TIME CLOCKS (RTCS) This application note describes crystal selection and layout techniques for connecting a 32,768Hz crystal to a real-time (RTC). It also provides information about oscillator circuit-design criteria, system design, and manufacturing issue. OSCILLATOR BASICS The oscillator used in RTCs is a CMOS inverter variation of a Pierce-type oscillator. Figure 1 shows a general configuration. These RTCs include integrated load capacitors (CL1 and CL2) and bias resistors. The Pierce oscillator utilizes a crystal operating in parallel-resonance mode. Crystals used in parallel-resonance mode will be specified for a certal frequency with a specific load capacitance. For the oscillator to run at the correct frequency, the oscillator circuit must load crystal with the correct capacitive load. Figure 1. RTC oscillator with internal load capacitors and bias resistors. ACCURACY The frequency accuracy of a crystal-based oscillator circuit is mainly dependent upon the accuracy of the crystal and the accuracy of the match between the crystal and the oscillator capacitive load. If the capacitive load is less than the crystal was designed for, the oscillator runs fast. If the capacitive load is greater than what the crystal was designed for, the oscillator runs slow. In addition to the errors from the crystal and the load match, crystals vary from their base frequency as the ambient temperature changes. RTCs use "tuning fork" crystals, which exhibit an error over temperature, as shown in Figure 2 . An error of 20ppm is equivalent to approximately 1 minute per month. 13 2013, December, Ver.04 IN1307 Figure 2. Crystal frequency vs. temperature. Note: If better accuracy is required, a TCXO such as the DS32kHz can be used CRYSTAL PARAMETERS Figure 3 shows the equivalent circuit for a crystal. Near the resonate frequency the circuit consists of a series circuit including motional inductance L1, motional resistance R1, and motional capacitance C1. The parallel component C O is the shunt capacitance of the crystal. Figure 3. Crystal equivalent circuit. The load capacitance CL is the capacitive load of the oscillating circuit as seen from the pins of the crystal. Figure 4 shows CL as a capacitance in parallel with the crystal. The load capacitors used in an oscillator circuit, CL1 and CL2, plus any stray capacitance in the circuit, combine to create the overall load capacitance. All RTCs have integrated CL1 and CL2 capacitors. Care should be taken to minimize stray capacitance in the PC board layout. The following formula shows the relationship between CL and load capacitor values: 14 2013, December, Ver.04 IN1307 Figure 4. Crystal load capacitors and equivalent parallel load. Most crystals allow a maximum drive level of 1μW. All RTCs run under 1μW. Drive level may be determined using the following formula: OSCILLATOR STARTUP TIME Oscillator startup times are highly dependent upon crystal characteristics, PC board leakage, and layout. High ESR and excessive capacitive loads are the major contributors to long startup times. A circuit using a crystal with the recommended characteristics and proper layout usually starts within one second. Table 1. Crystal Specifications Parameter Nominal Frequency Symbol Min Typ Max Units FO 32.768 kHz delta F/ FO ±20 ppm Load Capacitance CL 6 pF Temperature Turnover Point T0 Parabolic Curvature Constant k Quality Factor Q Frequency Tolerance 20 40,000 25 30 °C 0.042 ppm/°C 45 k pF 70,000 Series Resistance ESR Shunt Capacitance C0 1.1 1.8 Capacitance Ratio C0/C1 430 600 Drive Level DL 1 μW Note 1: Some devices allow higher ESR values, check the datasheet for specific requirements. 15 2013, December, Ver.04 IN1307 Table 2. Crystal Suppliers, cylinder-type (ESR=45k ) Note: Cylinder-type dimensions are barrel diameter and length, and exclude leads. All dimensions approximate. Table 3. Crystal Suppliers, Surface Mount Manufacturer Links http://www.citizen.co.jp/tokuhan/quartz/Catalog1/Crystals.htm http://www.eea.epson.com/ http://www.kdsj.co.jp/english.html http://www.pletronics.com/XTAL.htm#32 http://www.foxonline.com/ http://www.ecsxtal.com/thrucrys.htm 16 2013, December, Ver.04 IN1307 POWER CONSUMPTION Many RTCs are designed to operate from a battery supply. In a typical application, a small lithium battery can be used to run the oscillator and clock circuitry while the main supply is off. To maximize battery life, the oscillator must run using as little power as possible. To accomplish this, some design tradeoffs must be made. Negative Resistance For typical high-frequency oscillator circuits, it is normal for the circuit to be designed with a 5 or 10X margin for the ESR. Low-frequency crystals typically have higher ESRs. An RTC oscillator may have less than a 2X margin for negative resistance. An oscillator circuit with a low margin normally consumes less current. As a result, an RTC oscillator often is sensitive to relatively small amounts of stray leakage, noise, or an increase in ESR. The CL of the oscillator circuit influences the power consumption. An RTC with 12.5pF internal loads consumes more power than one that has 6pF loads. However, the oscillator with 12.5pF load capacitors is usually less susceptible to noise. CRYSTAL LAYOUT GUIDELINES Since the crystal inputs of RTCs have very high impedance (about 109 ), the leads to the crystal act like very good antenna, coupling high-frequency signals from the rest of the system. If a signal is coupled onto the crystal pins, it can either cancel out or add pulses. Since most of the signals on a board are at a much higher frequency than the 32.768kHz crystal, it is more likely to add pulses where none are wanted. These noise pulses get counted as extra clock "ticks" and make the clock appear to run fast. The following steps illustrate how to determine if noise is causing the RTC to run fast: 1. Power the system up and synchronize the RTC to a known accurate clock. 2. Turn the system power off. 3. Wait for a period of time (two hours, 24 hours, etc.). The longer the time period, the easier it is to measure the accuracy of the clock. 4. Turn the system on again, read clock, and compare to the known accurate clock. 5. Resynchronize the RTC to the known accurate clock. 6. Keep the system powered up and wait for a period of time equal to the period in Step 3. 7. Read the clock after waiting for the above period of time and compare it to the known accurate clock. By using the above steps, the accuracy of the clock can be determined both when the system is powered up and when the system is powered down. If the clock proves to be inaccurate when the system is powered up, but is accurate when the system is powered down, the problem is most likely due to noise from other signals in the system. However, if the clock is inaccurate both when the system is powered up and when it is powered down, then the problem is not due to noise from the system. Since it is possible for noise to be coupled onto the crystal pins, care must be taken when placing the external crystal on a PC board layout. It is very important to follow a few basic layout guidelines concerning the placement of the crystal on the PC board layout to ensure the extra clock ticks do not couple onto the crystal pins. 1. It is important to place the crystal as close as possible to the X1 and X2 pins. Keeping the trace lengths between the crystal and RTC as small as possible reduces the probability of noise coupling by reducing the length of the antenna. Keeping the trace lengths small also decreases the amount of stray capacitance. 2. Keep the crystal bond pads and trace width to the X1 and X2 pins as small as possible. The larger these bond pads and traces are, the more likely it is that noise can couple from adjacent signals. 17 2013, December, Ver.04 IN1307 3. If possible, place a guard ring (connected to ground) around the crystal. This helps isolate the crystal from noise coupled from adjacent signals. See Figure 2 for an illustration of using a guard ring around a crystal. 4. Try to ensure that no signals on other PC board layers run directly below the crystal or below the traces to the X1 and X2 pins. The more the crystal is isolated from other signals on the board, the less likely it is that noise is coupled into the crystal. There should be a minimum of 0.200 inches between any digital signal and any trace connected to X1 or X2. The RTC should be isolated from any component that generates electromagnetic radiation (EMR). This is true for discrete and module type RTCs. 5. It may also be helpful to place a local ground plane on the PC board layer immediately below the crystal. This helps to isolate the crystal from noise coupling from signals on other PC board layers. Note that the ground plane needs to be in the vicinity of the crystal only and not on the entire board. See Figure 5 for an illustration of a local ground plane. Note that the perimeter of the ground plane does not need to be larger than the outer perimeter of the guard ring. Note that care must be taken concerning the use of a local ground plane because of the stray capacitance that it introduces. The capacitance between the traces/pads and ground plane is added to the internal load capacitors (CL1 and CL2). Therefore, some factors must be taken into account when considering adding a local ground plane. For example, the capacitance due to the ground plane can be approximated by the following equation: Therefore, to determine if a ground plane is appropriate for a given design, the above parameters must be taken into account to ensure that the capacitance from the local ground plane is not sufficiently large enough to slow down the clock. Figure 5. Recommended layout for crystal. Checking For Oscillation The first impulse that a designer has when checking for oscillator operation often is to connect an oscilloscope probe to the oscillator input (X1) or output (X2) pin. Doing so is not recommended when using a Real-Time Clock. Since the oscillator is designed to run at low power (which extends operating time from a battery), loading the oscillator with an oscilloscope probe is likely to stop the oscillator. If the oscillator does not stop, the additional loading will reduce the signal amplitude, and may cause erratic operation, such as varying amplitude. Oscillation should therefore be verified indirectly. 18 2013, December, Ver.04 IN1307 Oscillation can be verified several ways. One method is to read the seconds register multiple times, looking for the data to increment. On RTCs with an OSF (Oscillator Stop Flag), clearing and then monitoring this bit will verify that the oscillator has started and is continuously running. These methods won’t work if the designer is troubleshooting a design and cannot communicate with the RTC. An alternate method is to check the square wave output on RTCs that have a square wave output. Check the datasheet to verify if the RTC must be written first to enable the oscillator and square wave output. Note that most RTC square wave outputs are open-drain, and require a pull up resistor for operation. The square wave output can also be used to verify the accuracy of the RTC, however, a frequency counter with sufficient accuracy must be used. Fast Clocks The following are the most common scenarios that cause a crystal-based RTC to run fast. 1. Noise coupling into the crystal from adjacent signals. This problem has been extensively covered above. Noise coupling usually causes an RTC to be grossly inaccurate. 2. Wrong crystal. An RTC typically runs fast if a crystal with a specified load capacitance (CL) greater than the RTC-specified load capacitance is used. The severity of the inaccuracy is dependent on the value of the CL. For example, using a crystal with a CL of 12pF on an RTC designed with a 6pF CL causes the RTC to be about 3 to 4 minutes per month fast. Slow Clocks The following are the most common scenarios that cause a crystal-based RTC to run slow. 1. Overshoots on RTC input pins. It is possible to cause a RTC to run slow by periodically stopping the oscillator. This can be inadvertently accomplished by noisy input signals to the RTC. If an input signal rises to a voltage that is greater than a diode drop (~0.3V) above VDD, the ESD protection diode for the input pin will forward bias, allowing the substrate to be flooded with current. This, in turn, stops the oscillator until the input signal voltage decreases to below a diode drop above VDD. This mechanism can cause the oscillator to stop frequently if input signals are noisy. Therefore, care should be taken to ensure there is no overshoot on input signals. Another situation that is common to overshoot problem is having an input to the RTC at 5V when the RTC is in battery-backup mode. This can be a problem in systems that systematically shut down certain circuits but keep others powered up. It is very important to ensure there are no input signals to the RTC that are greater than the battery voltage (unless stated otherwise in the device data sheet) when the device is in battery-backup mode. 2. Wrong crystal. A RTC typically runs slow if a crystal with a specified CL is less than the CL of the RTC. The severity of the inaccuracy is dependent on the value of the CL. 3. Stray capacitance. Stray capacitance between the crystal pins and/or to ground can slow an RTC down. Therefore, care must be taken when designing the PC board layout to ensure the stray capacitance is kept to a minimum. 4. Temperature. The further the operating temperature is from the crystal turnover temperature, the slower the crystal oscillates. See Figures 3 and 4. Clock Does Not Run The following are the most common scenarios that cause a RTC to not run. 1. The single most common problem when the clock does not run is that the CH (clock halt) or EOSC (enable oscillator) bit has not been set or cleared, as required. Many RTCs include a circuit that keeps the oscillator from running when power is first applied. This allows a system to wait for shipment to the customer, without drawing power from the backup battery. When the system is powered for the first time, the software/firmware must enable the oscillator and prompt the user for the correct time and date. 2. Surface mount crystals may have some N.C. (no connect) pins. Make sure that the correct pins from the crystal are connected to the X1 and X2 pins. 19 2013, December, Ver.04 IN1307 CRYSTAL MANUFACTURING ISSUES Tuning fork crystals should not be exposed to ultrasonic cleaning. They are susceptible to damage from resonant vibration. Crystals should not be exposed to temperatures above their maximum ratings. Exposure to excessive temperatures may damage the crystal, and usually increase the ESR. Crystal "cans" should not be soldered to a PC board. This is sometimes done to ground the case of the crystal. Soldering directly to the case of the crystal usually subjects the unit to excessive temperatures. RTCs should generally be used in noncondensing environments. Moisture forming around the oscillator conductors can cause leakage, which can cause the oscillator to stop. Conformal coatings can be used to protect the circuit, however, conformal coating may by itself cause problems. Some conformal coatings, especially epoxy-based materials, can have unacceptable levels of ionic contamination. In addition, conformal coatings can, if the PC board surface is not sufficiently cleaned prior to conformal coating, cause contaminants to concentrate around leads and traces. Solder flux residue can cause leakage between pins. RTC oscillator circuits are especially sensitive to leakage because of their low-power operation. Leakage between the oscillator input and output, or leakage to ground, often keep the oscillator from running. TYPICAL APPLICATION CIRCUIT 20 2013, December, Ver.04 IN1307 PACKAGE DIMENSION N SUFFIX PLASTIC DIP (MS – 001BA) A Dimension, mm 5 8 B 1 4 F Symbol MIN MAX A 8.51 10.16 B 6.1 7.11 C L C 5.33 D 0.36 0.56 F 1.14 1.78 -T- SEATING PLANE N G K D 0.25 (0.010) M M H J T NOTES: 1. Dimensions “A”, “B” do not include mold flash or protrusions. Maximum mold flash or protrusions 0.25 mm (0.010) per side. 21 G 2.54 H 7.62 J 0° 10° K 2.92 3.81 L 7.62 8.26 M 0.2 0.36 N 0.38 2013, December, Ver.04 0.25 (0.010) M T NOTES: 1. Dimensions “A”, “B” do not include mold flash or protrusions. Maximum mold flash or protrusions 0.25 mm (0.010) per side. K 2.92 3.81 L 7.62 8.26 M 0.2 N 0.38 0.36 IN1307 D SUFFIX SOIC (MS - 012AA) Dimension, mm A 8 5 B H 1 G P 4 D K MIN MAX A 4.8 5 B 3.8 4 C 1.35 1.75 D 0.33 0.51 F 0.4 1.27 R x 45 C -T- Symbol SEATING PLANE J F 0.25 (0.010) M T C M NOTES: 1. Dimensions A and B do not include mold flash or protrusion. 2. Maximum mold flash or protrusion 0.15 mm (0.006) per side for A; for B ‑ 0.25 mm (0.010) per side. 22 M G 1.27 H 5.72 J 0° 8° K 0.1 0.25 M 0.19 0.25 P 5.8 6.2 R 0.25 0.5 2013, December, Ver.04 IN1307 TEST FIXTURE for IN1363 & IN1307 Application Note IK SEMICON 23 2013, December, Ver.04 IN1307 Contents 1. Test fixture overview ................................................................................................................................. 25 1.1. Installing the hardware ..................................................................................................................... 25 1.2. Major Components .......................................................................................................................... 25 1.3. Basic Specification .......................................................................................................................... 27 2. Real Time Clock Program .......................................................................................................................... 28 2.1. Flow Chart ..................................................................................................................................... 28 2.2.1. Initialization Register Setting Up .................................................................................................... 30 2.2.2 Timer Register Setting Up............................................................................................................... 30 2.3 Register Set Up for IN1307 ............................................................................................................... 31 2.3.1. Initialization Register Setting Up .................................................................................................... 31 2.3.2 Timer Register Setting Up............................................................................................................... 31 2.4 Hyper Terminal Configuration ........................................................................................................... 32 3. Example Source for RTC ........................................................................................................................... 34 3.1. Read Current Time from IN1363 & IN1307 ........................................................................................ 34 3.2.Write Set Time for IN1363 & IN1307 ................................................................................................. 34 3.3. I2C Example Source for IN1363 & IN1307 ........................................................................................ 35 4. Test Procedure for RTC ............................................................................................................................. 38 4.1. Test Procedure for IN1363 ................................................................................................................ 38 4.2. Test Procedure for IN1307 ................................................................................................................ 38 24 2013, December, Ver.04 IN1307 1. Test fixture overview In order to supply convenient method for RTC Test, IK-SEMICON prepared test fixture. It’s controlled by Silabs MCU C8051F410, user can RTC test by using this fixture. 1.1. Installing the hardware IN1363/IN1307 is an IC compatible real time clock (RTC). As an application example, it demonstrates how to setup the RTC. This application note explain how to set the register value into a date and time value that can be put in the following form [YY]:[MM]:[DD]:[HH]:[MM]:[SS]. 1.2. Major Components Fig 1. Test board Schematic 25 2013, December, Ver.04 IN1307 Polarity + Adapter (Main Power DC12V) Polarity - IL1307 Backup Battery DC3V 2400m A Socket IN1363 Backup Battery initial switch Socket and PCB should be aligned in the same direction. Programming writing Connector IL1307 zone RS232C Fig 2 Top view of test fixture F H IN1307 A B C I IN1363 32.768KHz LED TP11 TP12 TP13 TP14 TP15 TP16 TP10 TP9 D SiLabs C8051F410 TP1 TP2 TP3 TP4 TP5 TP6 TP7 TP8 IN1363 IN1363 SOCKET SOCKET J 32.768KHz E IN1307 IN1307 SOCKET SOCKET K MAX3223E F RS232C Fig 3 Layout of test fixture. 26 2013, December, Ver.04 IN1307 1.3. Basic Specification A. 12V DC-JACK : Power Terminal This power terminal normally is connected to the 12V power supply. B. Init Switch This switch initialize time to 23 July 2012, current time to 14:03:02(IN1363). C. LED This LED blinking every 1 seconds. if there is a power on the test fixture. D. Test Point In/Output pin of the MCU is connected. If need the user, use as the test pin. E. Debugger Connector This test program exchanges with PC(Personal Computer) through this debugger connector. F. RS232C Female Connector User can see the test time through this connector. G. 32.768KHz Connection of the standard quartz resonator for the frequency 32.768KHz. IN1363 can operate from external oscillator with the frequency 32.768KHz Note : To oscillation the 32.768KHz , Reset to the bit TEST1 H. IN1307_BAT If you test the IN1307,Connect Battery on the IN1307_BAT. I. J. IN1363_BAT If you test the IN1363, Connect Battery on the IN1363_BAT Note: Although the power eliminate, the Real Time Clock is working if the battery is connected on the IN1307/IN1363_BAT IN1363_SOCKET To test of IN1363 RTC, it should select IN1363_SOCKET. K. IN1307_SOCKET To test of IN1307 RTC, it should select IN1307_SOCKET. Note: To avoid any confusion by program selector, only one IC should be selected by socket. 27 2013, December, Ver.04 IN1307 2. Real Time Clock Program 2.1. Flow Chart Power ON : IN1363 Read data : Address 0x00 No (READ data & 0x80) == 0 Yes DTE : Initialize by Memory Nodata DTE : Continue Start at 1363 Yes IN1363 Initialize Write Data * Bit TEST1 = 0 ACK received No 12[YY]:07[MM]:23[DD]:14[HH]:03[MM]:02[SS] Yes DTE : I2C Error No Ack Read data :Address from 0x02 to 0x8 IN1363 Initialize Write Data ACK received No TEST1 bit = 0; Yes No DTE : 9600bps RTC DISPLAY Address, Data 0x02, 0x02 DTE : RTC No ACK in READ Address, Data 0x03, 0x03 Address, Data 0x04, 0x14 SW Press Yes Address, Data 0x05, 0x23 DTE : Initialize by SW press Address, Data 0x07, 0x07 Yes IN1363 Initialize Write Data Address, Data 0x08, 0x12 Fig3. Flow Chart for IN1363 28 2013, December, Ver.04 IN1307 Power ON : IN1307 Read data : Address 0x00 No (READ data & 0x80) == 0 Yes DTE : Initialize by Memory Nodata DTE : Continue Start at 1307 Yes IN1307 Initialize Write Data * Bit CH = 0 12[YY]:06[MM]:15[DD]:5[DAY]:13[HH]:10[MM]:5[SS] ACK received No Yes DTE : I2C Error No Ack Read data :Address from 0x00 to 0x06 IN1307 Initialize Write Data ACK received No CH bit = 0; Yes No DTE : 9600bps RTC DISPLAY Address, Data 0x00, 0x05 DTE : RTC No ACK in READ Address, Data 0x01, 0x10 Address, Data 0x02, 0x13 SW Press Address, Data 0x03, 0x05 Yes Address, Data 0x04, 0x15 DTE : Initialize by SW press Yes IN1307 Initialize Write Data Address, Data 0x05, 0x06 Address, Data 0x06, 0x12 Address, Data 0x07, 0x00 Fig4. Flow Chart for IN1307 29 2013, December, Ver.04 IN1307 2.2. Register Set Up for IN1363 2.2.1. Initialization Register Setting Up It is necessary to enable the generation (bit TEST1 = 0) when setting the initial configurations.. Register Ad- Register Name Initialize Write Data Contents 0x00H Control/Status 1 0x00 0x01H Control/Status 2 0x00 TEST1 bit = 0 (normal mode) STOP bit = 0 (RTC source clock) TESTC bit = 0 (normal op) AIE bit = 0 (Alarm int disabled) TIE bit = 0 (Timer int disabled) 0x0DH CLKPUT control - 0x0EH Timer Control - 0x0FH Timer - dress 2.2.2 Timer Register Setting Up Register Ad- Register Name Initialize Write Data 0x02H Seconds 0x02 0x03H Minutes 0x03 0x04H Hours 0x14 0x05H Dates 0x23 0x06H Day of week - 0x07H Century/month 0x07 0x08H Year 0x12 0x09H Minute alarm - 0x0AH Hour alarm - 0x0BH Date alarm - 0x0CH Weekday alarm Contents dress Sunday=0,Monday=1,Tuesday=2, Wednesday=3,..., Saturday=6 Bit7 ‘C’ of the months/century register indicates century for year 19xx (bit7=1), and year 20xx (bit7=0). For example, we want to set the date for 23 July 2012, current time to 12:03:02, and then we need to call. 1. 2. 3. 4. 5. 6. Seconds setup Minutes setup Hours setup Dates setup Month setup Year setup : : : : : : rtc_write( SECONDS, 0x02); rtc_write( MINUTES, 0x03); rtc_write( HOURS, 0x14); rtc_write( DATES, 0x23); rtc_write( MONTH, 0x07); rtc_write( YEAR, 0x12); 30 2013, December, Ver.04 IN1307 2.3 Register Set Up for IN1307 2.3.1. Initialization Register Setting Up It is necessary to enable the generation (bit CH = 0) when setting the initial configurations.. Register Address Register Name Initialize Write Data Contents 0x00H.Bit8 Control/Status 1 0x00 CH bit = 0 (normal mode) Register Name Initialize Write Data Contents 0x00H Seconds 0x05 0x01H Minutes 0x10 0x02H Hours 0x13 0x03H Day 0x05 0x04H Date 0x15 0x05H Month 0x06 0x06H Year 0x12 0x07H Control 2.3.2 Timer Register Setting Up Register Address Range 1-7 For example, we want to set the date for 23 June 2012, current time to 13:10:05, and then we need to call. 1. 2. 3. 4. 5. 6. 7. Seconds setup Minutes setup Hours setup Day setup Dates setup Month setup Year setup : : : : : : : rtc_write( 0x00, 0x05); rtc_write( 0x01, 0x10); rtc_write( 0x02, 0x13); rtc_write( 0x03, 0x05); rtc_write( 0x04, 0x15); rtc_write( 0x05, 0x06); rtc_write (0x06 , 0x12); 31 2013, December, Ver.04 IN1307 2.4 Hyper Terminal Configuration 1. 2. 3. 4. 5. Bits per second : 9600 BPS Data bit : 8 bit Parity bit : None Stop bits : 1 bit Flow Control : None Fig5. Example test program for IN1363 Run the Serial terminal and make sure the baud rate is set correctly at 9600bps Fig6. IN1363 RTC Data on Serial Terminal 32 2013, December, Ver.04 IN1307 Fig7. IN1307 RTC Data on Serial Terminal 33 2013, December, Ver.04 IN1307 3. Example Source for RTC This documentation shows an example of a main function to setup and read/write data. If you request example source code, we can provide source codes. 3.1. Read Current Time from IN1363 & IN1307 Slave Address of IN1363 = 0xA2 Slave Address of IN1307 = 0xD0; 3.2.Write Set Time for IN1363 & IN1307 34 2013, December, Ver.04 IN1307 3.3. I2C Example Source for IN1363 & IN1307 #ifdef IN1363 sbit SCL sbit SDA #endif = P1^7; = P1^6; // #ifdef IN1307 sbit SDA sbit SCL #endif = P0^2; = P0^1; void i2c_start(void) // START condition { SDA = HIGH; DelayTimeLoop(); SCL = HIGH; DelayTimeLoop(); SDA = LOW; DelayTimeLoop(); SCL = LOW; DelayTimeLoop(); } void i2c_stop(void) // STOP condition { SCL = HIGH; DelayTimeLoop(); SDA = HIGH; DelayTimeLoop(); } /* Clock pulse generation. The function returns data or acknowledgment unsigned char i2c_clock(void)//bit i2c_clock(void) { bit level; // state of SDA line SCL = 1; DelayTimeLoop(); while (!SCL); // if a pulse was stretched DelayTimeLoop(); level = SDA; DelayTimeLoop(); SCL = 0; return (level); } bit */ /* Writing a byte to a slave, with most significant bit first. The function returns acknowledgment bit.*/ unsigned char i2c_write(unsigned char byte) { unsigned char mask = 0x80; unsigned char aaa; while (mask) { if (byte & mask) 35 2013, December, Ver.04 IN1307 SDA = 1; else SDA = 0; i2c_clock(); mask >>= 1; } aaa = i2c_clock(); return (aaa); } /* Reading byte from a slave, with most significant bit first. The parameter indicates, whether to acknowledge (1) or not (0) */ unsigned char i2c_read(unsigned char acknowledgment) { uchar mask = 0x80, byte = 0x00; while (mask) { if (i2c_clock()) byte |= mask; mask >>= 1; /* next bit to receive */ } if (acknowledgment) { SDA = 0; i2c_clock(); SDA = 1; } else { SDA = 1; i2c_clock(); } return (byte); } unsigned char rtc_read_7_byte(unsigned char addr) { unsigned char status , i; i2c_start(); if (!i2c_write(0xA2 )){//0xA2 is Slave Address for IN1363, 0xD2 is for IN1307 DelayTimeLoop(); if (!i2c_write(addr)){ i2c_start(); if (!i2c_write(0xA2 | 0x01)){ IN1307’s slave address is 0xD2 for(i=0;i<6;i++){ Receive_Data[i] = i2c_read(1); } Receive_Data[6] = i2c_read(0); } else { status = 1; } } else{ status = 1; 36 2013, December, Ver.04 IN1307 } } else status = 1; i2c_stop(); return(status); } 37 2013, December, Ver.04 IN1307 4. Test Procedure for RTC 4.1. Test Procedure for IN1363 1. 2. 3. 4. 5. 6. 7. 8. 9. Make sure that test fixture is power off. Place IN1363 on IN1363_SOCKET of test fixture. Connect the Battery on IN1363_BAT. Run the Serial terminal and make sure the baud rate is set correctly at 9600bps After turning on the power of test fixture, identify whether Green LED of Status Indicator is flickering. If that’s flickering every 1S, it indicates IN1363 working . Method for the program is refer to the Chapter 2. Data is displayed in Serial Terminal window like to Fig6. refer to Fig6 And then test fixture is power off. Wait for a period of time ( two hours, 10 minutes, etc .). Turn the test fixture on again, and check the time. the amount time as power off is passed . 4.2. Test Procedure for IN1307 1. 2. 3. 4. 5. 6. 7. 8. 9. Make sure that test fixture is power off. Place IN1363 on IN1307_SOCKET of test fixture. Connect the Battery on IN1307_BAT. Run the Serial terminal and make sure the baud rate is set correctly at 9600bps After turning on the power of test fixture, identify whether Green LED of Status Indicator is flickering. If that’s flickering every 1S, it indicates IN1307 working . Method for the program is refer to the Chapter 2. Data is displayed in Serial Terminal window like to Fig7. refer to Fig7 And then test fixture is power off. Wait for a period of time ( two hours, 10 minutes, etc .). Turn the test fixture on again, and check the time. the amount time as power off is passed . 38 2013, December, Ver.04