Description

The PCF8583 is a clock/calendar circuit based on a 2048-bit static CMOS RAM organized as 256 words by 8 bits. Addresses and data are transferred serially via the two-line bidirectional I2C-bus. The built-in word address register is incremented automatically after each written or read data byte. Address pin A0 is used for programming the hardware address, allowing the connection of two devices to the bus without additional hardware.The built-in 32.768 kHz oscillator circuit and the first 8 bytes of the RAM are used for the clock/calendar and counter functions. The next 8 bytes may be programmed as alarm registers or used as free RAM space. The remaining 240 bytes are free RAM locations

Features

  • I2C-bus interface operating supply voltage: 2.5 V to 6 V
  • Clock operating supply voltage (0 to +70 °C): 1.0 V to 6.0 V
  • 240 ´ 8-bit low-voltage RAM· Data retention voltage: 1.0 V to 6 V
  • Operating current (at fSCL = 0 Hz): max. 50 mA
  • Clock function with four year calendar
  • Universal timer with alarm and overflow indication
  • 24 or 12 hour format· 32.768 kHz or 50 Hz time base
  • Serial input/output bus (I2C)
  • Automatic word address incrementing
  • Programmable alarm, timer and interrupt function
  • Slave address:– READ: A1 or A3– WRITE: A0 or A2.

Package

PCF8583

Application

The PCF8583 device is connected to a port of the AVR microcontroller.

Software 1

This program shows how to use the PCF8583 I2C clock device the PCF8583 is a PHILIPS device. The time can be set and read with a terminal emulator. Set baud rate at 9600.

Software 2

The program reads the time from the {CF8583 device and shows it on a 20*4 LCD display with big numbers.

AVR-BASCOM program code software 1

' *****************************************************************************
' * Title         : Real Time Clock PCF8583
' * Version       : 1.0
' * Last Updated :  17.12.2007
' * Target        : ATTiny2313 internal oscillator enabled @ 8Mhz
' * Author        : www.avrprojects.net
' * Program code  : BASCOM AVR
' * Hardware req. : Real Time Clock PCF8583
' * Description   : This program shows how to use the PCF8583 I2C clock device
' *                 the PCF8583 is a PHILIPS device. The time can be set and read
' *                 with a terminal emulator. Set baud rate at 9600.
' *****************************************************************************

Dim Temp As Byte , I As Byte , Tm(5) As Byte , Answer As String * 1
Dim Second As Byte , Minute As Byte , Hour As Byte , Day As Byte , Month As Byte , Year As Byte

Config Lcdpin = Pin , Db4 = Portd.3 , Db5 = Portd.2 , Db6 = Portd.1 , Db7 = Portd.0 , E = Portd.6 , Rs = Portd.7

Config Lcd = 20 * 4

Config Sda = Portb.0 , Scl = Portb.1

$baud = 9600

$crystal = 10000000

Config Portd = Output

Declare Sub Settime()
Declare Sub Gettime()

Print "Real Time Clock PCF8583"
Call Gettime

Input "Set Time (y/n)" , Answer

If Answer = "y" Then Call Settime()

Do
Call Gettime()
Wait 1
Loop

Sub Settime()
Input "Set Seconds: " , Second
Input "Set Minutes: " , Minute
Input "Set Hour: " , Hour
Input "Set Day: " , Day
Input "Set Month:" , Month
Input "Set Year: " , Year

    Tm(1) = Makebcd(second)                                 'seconds
    Tm(2) = Makebcd(minute)                                 'minutes
    Tm(3) = Makebcd(hour)                                   'hours
    Tm(4) = Makebcd(day)                                    'days
    Tm(5) = Makebcd(month)                                  'months

    I2cstart                                                'generate start
    I2cwbyte &HA0                                           'write address
    I2cwbyte 0                                              'select control register
    I2cwbyte 8                                              'set year and day bit for masking
    I2cstart                                                'repeated start
    I2cwbyte &HA0                                           'write mode
    I2cwbyte 2                                              'select seconds Register
    For I = 1 To 5
      I2cwbyte Tm(i)
    Next                                                    'write time
    I2cstop
End Sub Settime()

Sub Gettime()
   For I = 1 To 5
       Temp = I + 1
       I2cstart
       I2cwbyte &HA0                                        'write addres of PCF8583
       I2cwbyte Temp                                        'select register
       I2cstart                                             'repeated start
       I2cwbyte &HA1                                        'write address for reading info
       I2crbyte Tm(i) , Nack                                'read data
    Next
I2cstop

Print Hex(tm(4)) ; "-" ; Hex(tm(5)) ; "-200" ; Year ; " " ; Hex(tm(3)) ; ":" ; Hex(tm(2)) ; ":" ; Hex(tm(1))

End Sub Gettime()