Example program provided by Embedded Systems Academy, Copyright 2000 Visit www.esacademy.com/faq/progs for more examples This example: I2CRTC - name of application: main.c ==================================================== Demonstration of talking to a Real Time Clock device on the I2C bus. Hardware requirements ===================== Phytec RDK 591 with Philips 591 Software requirements ===================== Phytec Flash Tools (part of RDK 591) www.phytec.com Raisonance 8051 compiler system - EVAL version sufficient www.raisonance.com or Keil 8051 Compiler System - EVAL version sufficient www.keil.com Optional: Development Assistant-C by RistanCASE www.ristancase.ch Tested using ============ Raisonance 51 Toolset version 6.1.1 Keil C51 Toolset version 6.00 Application description ============================================= Raisonance specific files have their names prefixed with 'r'. Keil specific files have their names prefixed with 'k'. The same source files are used for both compilers. This program initializes the Real Time Clock to a specific date and time and then repeatedly reads back the current date and time. The program results are output through the UART. Connect using: 9600 baud, 8-N-1, no flow control. This program does not demonstrate the most efficient way of reading and writing sequential registers, however it does demonstrate the I2C procedure in the most simple way. rtc_write_byte and rtc_read_byte do not return until there is either an error or a successful storage. Both functions wait up to 22ms for the RTC to be ready using a polling method. The status may be read in the variable i2c_status. This program may be easily modified to do the following: 1. trigger an interrupt once a second, once a minute, etc. 2. Allow the user to enter the current date and time via the UART 3. Display the weekday 4. Sample the potentiometer and timestamp the sample 5. Set alarms