RTC using ghraphical LCD 2003

101
REAL TIME CLOCK DISPLAY USING GRAPHICAL LCD CONTENTS ABSTRACT CHAPTER 1: INRODUCTION 1 1.1 Circuit description 2 1.2 Embedded system 4 1.3 Characteristics of embedded system 4 1.4 Debugging 6 1.5 Design of embedded system 6 CHAPTER 2: ATMEGA 8515 9 2.1 Features 10 2.2 Pin configuration 11 2.3 block diagram 12 2.4 Pin description 14 2.5 oscillator characteristics 16

Transcript of RTC using ghraphical LCD 2003

Page 1: RTC using ghraphical LCD 2003

REAL TIME CLOCK DISPLAY USING GRAPHICAL LCD

CONTENTS

ABSTRACT

CHAPTER 1: INRODUCTION 1

1.1 Circuit description 2

1.2 Embedded system 4

1.3 Characteristics of embedded system 4

1.4 Debugging 6

1.5 Design of embedded system 6

CHAPTER 2: ATMEGA 8515 9

2.1 Features 10

2.2 Pin configuration 11

2.3 block diagram 12

2.4 Pin description 14

2.5 oscillator characteristics 16

CHAPTER 3: DS1307 17

3.1 Features of DS1307 18

3.2 Pin description 18

3.3 Typical operating circuit 19

3.4 Block diagram 20

3.5 Signal description 20

3.6 Time keeper registers 23

3.7 Control registers 23

Page 2: RTC using ghraphical LCD 2003

3.8 2-wire serial data bus 24

3.9 2 –bus configurations 24

3.10 Data transfer on 2-wire serial bus 25

3.11 Slave receiver mode 25

3.11.1 Data –write slave mode 27

3.11.2 Data –read slave mode 27

CHAPTER 4: GRAPHICAL LCD 28

4.1 Introductions 29

4.2 A map of lcd pixels 29

4.3 pin description 30

4.4 display control instruction 31

CHAPTER 5: POWERSUPPLY 33-34

CHAPTER 6: CIRCUIT DIAGRAM AND CODING 35-72

Page 3: RTC using ghraphical LCD 2003

List of Figure

Figure No. Figure Name Page No

2.2.1

2.3.1

2.5.1

3.3.1

3.4.1

3.8.1

3.9.1

4.1.1

4.2.1

6.1.1

Pin configuration of ATMGA 8515

Overview of ATMGA 8515

Oscillator characteristics

Typical operating circuit of DS1307

Block diagram of DS1307

2-wire bus configuration

Data transfer on 2-wire

Picture of graphical LCD

A map of LCD pixels

Schematic diagram of RTC using graphical LCD

11

12

15

19

20

24

25

29

29

33

Page 4: RTC using ghraphical LCD 2003

List of Tables

Table No. Table Name Page No

4.3.1 Pin description of graphical LCD 30

Page 5: RTC using ghraphical LCD 2003

Abstract

AIM:

To display the real time on graphical LCD

DESCRIPTION:

The aim of this project is to interface the graphical LCD to display the data in different graphical

formats and to display time in addition to text and numeric formats on the graphical LCD. This project gives

details of a simple interface technique between a display graphic and a micro-controller.

We had used Atmega-8515 which is 8-bit microcontroller and JHD12864E Graphical LCD to

display the graphical Images. The Graphical LCD we have used is 128 X 64 on which we can display any

type of images. The display is split logically in two half’s. It contains two controllers with controller 1 (Chip

select 1) controlling the left half of the display and controller 2 (Chip select 2) controlling the right half.

Each controller must be addressed independently. The page addresses, 0-7, specify one of the 8 horizontal

pages which are 8 bits (1 byte) high. To display the image on the LCD we should configure the pixel by

selecting the particular half (right half /left half) and page (form 0 to 7), we are using DS1307 and AT24C08

to display the clock in Graphical LCD.

The purpose of using controller is to clear the display, move the cursor, to give the data to be

displayed and controlling the Graphic LCD operations. It is used to display soft font text, line drawing;

graphic symbol and icon display, pixel setting etc. Using this graphic LCD we can create images which we

can’t create by using normal LCD display. Using normal LCD we can display only characters and symbols.

The Graphical LCD often require more initial time and effort to get them running than alphanumeric LCD’s

but they do not have the character limits of such LCD displays. Here we can create images using pixels like

in our C programming.

To prepare data that can be embedded in our program so that we can display a specific image on the

LCD we need to prepare the data for each pixel on the LCD which can be done manually or by using some

modern software’s that translates a bitmap file to display data.

Page 6: RTC using ghraphical LCD 2003

REQUIREMENTS:

HARDWARE REQUIREMENTS:

MICROCONTROLLER

GRAPHICAL LCD

DS1307

SWITCHES

PCB and Connecting wires

SOFTWARE REQUIREMENTS:

Functionality of all above components

Embedded c programming

Page 7: RTC using ghraphical LCD 2003
Page 8: RTC using ghraphical LCD 2003

Chapter 1

INTRODUCTION

Page 9: RTC using ghraphical LCD 2003

1.1CIRCUIT DESCRIPTION

DESIGNING:

Since the main intension of this project is to design a real time clock display on graphical this

application there are few steps that has been performed i.e.

1) Designing the power supply for the entire circuitry.

2) Selection of microcontroller that suits our application.

Selection LCD.

3) In order to fulfill of RTC

4) Selection of LCD.

Complete studies of all the above points are useful to develop this project.

BLOCK DIAGRAM:

GRAPHICAL LCD

MICROCONTROLLER

Atmega 8515

DS 1307

SWITCHESSWITCHES

Page 10: RTC using ghraphical LCD 2003

SELECTION OF MICROCONTROLLER:

We are selecting Atmega 8515 AVR microcontroller

There are minimum five requirements for proper operation of microcontroller.

Those are:

1) power supply section

2) pull-ups for ports

3) Reset circuit

4) Crystal circuit

5) ISP circuit (for program dumping)

SELECTION OF RTC:

Here in this project I selected i2c protocol based DS1307 RTC. Real-time clock counts

seconds, minutes, hours, date of the month, month, day of the week, and year with leap-year compensation

valid up to 2100.RTC contains particular memory locations to store the seconds, minutes, hours, date of the

month, month, day of the week whenever power up these locations will count. By using push button

switches we can change these locations to set the current time.

CONNECTIONS OF RTC:

In this application we are using i2c protocol based IC DS1307.The 5th 6th pin’s of IC is

connected to the PC.0, PC.7 of microcontroller respectively.

CIRCUIT OPERATION:

The main aim of the project is to interface the graphical LCD and DS1307 (RTC) to the

controller .Here our application program is reading the data from DS1307 through I2c protocol. And

displaying on the graphical LCD and 4 switches are for adjusting the time.

Page 11: RTC using ghraphical LCD 2003

1.2 EMBEDDED SYSTEMS

Embedded systems are electronic devices that incorporate microprocessors with in their

implementations. The main purposes of the microprocessors are to simplify the system design and provide

flexibility. Having a microprocessor in the device helps in removing the bugs, making modifications, or

adding new features are only matter of rewriting the software that controls the device. Or in other words

embedded computer systems are electronic systems that include a microcomputer to perform a specific

dedicated application. The computer is hidden inside these products. Embedded systems are ubiquitous.

Every week millions of tiny computer chips come pouring out of factories finding their way into our

everyday products.

Embedded systems are self-contained programs that are embedded within a piece of hardware.

Whereas a regular computer has many different applications and software that can be applied to various

tasks, embedded systems are usually set to a specific task that cannot be altered without physically

manipulating the circuitry. Another way to think of an embedded system is as a computer system that is

created with optimal efficiency, thereby allowing it to complete specific functions as quickly as possible.

Embedded systems designers usually have a significant grasp of hardware technologies. They use

specific programming languages and software to develop embedded systems and manipulate the equipment.

When searching online, companies offer embedded systems development kits and other embedded systems

tools for use by engineers and businesses.

Embedded systems technologies are usually fairly expensive due to the necessary development time

and built in efficiencies, but they are also highly valued in specific industries. Smaller businesses may wish

to hire a consultant to determine what sort of embedded systems will add value to their organization.

Page 12: RTC using ghraphical LCD 2003

1.3 CHARACTERISTICS:

Two major areas of differences are cost and power consumption. Since many embedded systems are

produced in tens of thousands to millions of units range, reducing cost is a major concern. Embedded

systems often use a (relatively) slow processor and small memory size to minimize costs.

The slowness is not just clock speed. The whole architecture of the computer is often intentionally

simplified to lower costs. For example, embedded systems often use peripherals controlled by synchronous

serial interfaces, which are ten to hundreds of times slower than comparable peripherals used in PCs.

Programs on an embedded system often run with real-time constraints with limited hardware resources:

often there is no disk drive, operating system, keyboard or screen. A flash drive may replace rotating media,

and a small keypad and LCD screen may be used instead of a PC's keyboard and screen.

Firmware is the name for software that is embedded in hardware devices, e.g. in one or more

ROM/Flash memory IC chips. Embedded systems are routinely expected to maintain 100% reliability while

running continuously for long periods, sometimes measured in years. Firmware is usually developed and

tested too much harsher requirements than is general-purpose software, which can usually be easily restarted

if a problem occurs.

PLATFORM:

There are many different CPU architectures used in embedded designs. This in contrast to the

desktop computer market which is limited to just a few competing architectures mainly the Intel/AMD x86

and the Apple/Motorola/IBM Power PC’s which are used in the Apple Macintosh. One common

configuration for embedded systems is the system on a chip, an application-specific integrated circuit, for

which the CPU was purchased as intellectual property to add to the IC's design.

TOOLS:

Like a typical computer programmer, embedded system designers use compilers, assemblers and

debuggers to develop an embedded system. Those software tools can come from several sources:

Software companies that specialize in the embedded market Ported from the GNU software

development tools. Sometimes, development tools for a personal computer can be used if the embedded

processor is a close relative to a common PC processor. Embedded system designers also use a few software

tools rarely used by typical computer programmers. Some designers keep a utility program to turn data files

into code, so that they can include any kind of data in a program. Most designers also have utility programs

to add a checksum or CRC to a program, so it can check its program data before executing it.

Page 13: RTC using ghraphical LCD 2003

OPERATING SYSTEM:

They often have no operating system, or a specialized embedded operating system (often a real-time

operating system), or the programmer is assigned to port one of these to the new system.

DEBUGGING:

Debugging is usually performed with an in-circuit emulator, or some type of debugger that can

interrupt the micro controller’s internal microcode. The microcode interrupt lets the debugger operate in

hardware in which only the CPU works. The CPU-based debugger can be used to test and debug the

electronics of the computer from the viewpoint of the CPU.

Developers should insist on debugging which shows the high-level language, with breakpoints and

single stepping, because these features are widely available. Also, developers should write and use simple

logging facilities to debug sequences of real-time events. PC or mainframe programmers first encountering

this sort of programming often become confused about design priorities and acceptable methods. Mentoring,

code-reviews and ego less programming are recommended.

1.4 DESIGN OF EMBEDDED SYSTEMS:

The electronics usually uses either a microprocessor or a microcontroller. Some large or old systems

use general-purpose mainframes computers or minicomputers.

START-UP:

All embedded systems have start-up code. Usually it disables interrupts, sets up the electronics, tests

the computer (RAM, CPU and software), and then starts the application code. Many embedded systems

recover from short-term power failures by restarting (without recent self-tests). Restart times under a tenth

of a second are common.

Many designers have found one of more hardware plus software-controlled LED’s useful to

indicate errors during development (and in some instances, after product release, to produce troubleshooting

diagnostics). A common scheme is to have the electronics turn off the LED(s) at reset, whereupon the

software turns it on at the first opportunity, to prove that the hardware and start-up software have performed

their job so far. After that, the software blinks the LED(s) or sets up light patterns during normal operation,

to indicate program execution progress and/or errors. This serves to reassure most technicians/engineers and

some users.

Page 14: RTC using ghraphical LCD 2003

THE CONTROL LOOP:

In this design, the software has a loop. The loop calls subroutines. Each subroutine manages a part of

the hardware or software. Interrupts generally set flags, or update counters that are read by the rest of the

software. A simple API disables and enables interrupts. Done right, it handles nested calls in nested

subroutines, and restores the preceding interrupt state in the outermost enable. This is one of the simplest

methods of creating an exocrine.

Typically, there's some sort of subroutine in the loop to manage a list of software timers, using a

periodic real time interrupt. When a timer expires, an associated subroutine is run, or flag is set. Any

expected hardware event should be backed-up with a software timer. Hardware events fail about once in a

trillion times.

State machines may be implemented with a function-pointer per state-machine (in C++, C or

assembly, anyway). A change of state stores a different function into the pointer. The function pointer is

executed every time the loop runs.

Many designers recommend reading each IO device once per loop, and storing the result so the logic

acts on consistent values. Many designers prefer to design their state machines to check only one or two

things per state. Usually this is a hardware event, and a software timer. Designers recommend that

hierarchical state machines should run the lower-level state machines before the higher, so the higher run

with accurate information.

Complex functions like internal combustion controls are often handled with multi-dimensional

tables. Instead of complex calculations, the code looks up the values. The software can interpolate between

entries, to keep the tables small and cheap.

One major disadvantage of this system is that it does not guarantee a time to respond to any

particular hardware event. Careful coding can easily assure that nothing disables interrupts for long. Thus

interrupt code can run at very precise timings. Another major weakness of this system is that it can become

complex to add new features. Algorithms that take a long time to run must be carefully broken down so only

a little piece gets done each time through the main loop.

This system's strength is its simplicity, and on small pieces of software the loop is usually so fast that

nobody cares that it is not predictable. Another advantage is that this system guarantees that the software

will run. There is no mysterious operating system to blame for bad behavior.

USER INTERFACES:

Interface designers at PARC, Apple Computer, Boeing and HP minimize the number of types of user

actions. For example, use two buttons (the absolute minimum) to control a menu system (just to be clear,

Page 15: RTC using ghraphical LCD 2003

one button should be "next menu entry" the other button should be "select this menu entry"). A touch-screen

or screen-edge buttons also minimize the types of user actions.

Another basic trick is to minimize and simplify the type of output. Designs should consider using a

status light for each interface plug, or failure condition, to tell what failed. A cheap variation is to have two

light bars with a printed matrix of errors that they select- the user can glue on the labels for the language that

she speaks.

For example, Boeing's standard test interface is a button and some lights. When you press the button,

all the lights turn on. When you release the button, the lights with failures stay on. The labels are in Basic

English.

Designers use colors. Red defines the users can get hurt- think of blood. Yellow defines something

might be wrong. Green defines everything's OK.

Another essential trick is to make any modes absolutely clear on the user's display. If an interface

has modes, they must be reversible in an obvious way. Most designers prefer the display to respond to the

user. The display should change immediately after a user action. If the machine is going to do anything, it

should start within 7 seconds, or give progress reports.

One of the most successful general-purpose screen-based interfaces is the two menu buttons and a

line of text in the user's native language. It's used in pagers, medium-priced printers, network switches, and

other medium-priced situations that require complex behavior from users. When there's text, there are

languages. The default language should be the one most widely understood.

Page 16: RTC using ghraphical LCD 2003

CHAPTER 2

ATMEGA8515

Page 17: RTC using ghraphical LCD 2003

ATMEGA8515

2.1 FEATURES:

High-performance, Low-power AVR® 8-bit Microcontroller

RISC Architecture

–130 Powerful Instructions – Most Single Clock Cycle Execution

– 32 x 8 General Purpose Working Registers

– Fully Static Operation

– Up to 16 MIPS Throughput at 16 MHz

– On-chip 2-cycle Multiplier

Nonvolatile Program and Data Memories

– 8K Bytes of In-System Self-programmable Flash

Endurance: 10,000 Write/Erase Cycles

– Optional Boot Code Section with Independent Lock bits

In-System Programming by On-chip Boot Program

True Read-While-Write Operation

– 512 Bytes EEPROM

Endurance: 100,000 Write/Erase Cycles

– 512 Bytes Internal SRAM

– Up to 64K Bytes Optional External Memory Space

Page 18: RTC using ghraphical LCD 2003

– Programming Lock for Software Security

Peripheral Features

– One 8-bit Timer/Counter with Separate Prescaler and Compare Mode

– One 16-bit Timer/Counter with Separate Prescaler, Compare Mode, and

Capture Mode

– Three PWM Channels

– Programmable Serial USART

– Master/Slave SPI Serial Interface

– Programmable Watchdog Timer with Separate On-chip Oscillator

–On-chip Analog Comparator

Special Microcontroller Features

– Power-on Reset and Programmable Brown-out Detection

– Internal Calibrated RC Oscillator

– External and Internal Interrupt Sources

– Three Sleep Modes: Idle, Power-down and Standby

I/O and Packages

– 35 Programmable I/O Lines

– 40-pin PDIP, 44-lead TQFP, 44-lead PLCC, and 44-pad QFN/MLF

Operating Voltages

– 2.7 - 5.5V for ATmega8515L

– 4.5 - 5.5V for ATmega8515

Speed Grades

–0 - 8 MHz for ATmega8515L

–0 - 16 MHz for ATmega8515

2.2 Pin Configurations

Page 19: RTC using ghraphical LCD 2003

2.2.1 Pin configuration of ATMGA 8515

2.3 BLOCK DIAGRAM

The ATmega8515 is a low-power CMOS 8-bit microcontroller based on the AVR enhanced

RISC architecture. By executing powerful instructions in a single clock cycle, the ATmega8515 achieves

throughputs approaching 1 MIPS per MHz allowing the system designer to optimize power consumption

versus processing speed.

Page 20: RTC using ghraphical LCD 2003

2.3.1 Overview of ATMGA 8515

The AVR core combines a rich instruction set with 32 general purpose working registers. All

the 32 registers are directly connected to the Arithmetic Logic Unit (ALU), allowing two independent

registers to be accessed in one single instruction executed in one clock cycle. The resulting architecture is

more code efficient while achieving throughputs up to ten times faster than conventional CISC

microcontrollers.

The ATmega8515 provides the following features: 8K bytes of In-System Programmable

Flash with Read-While-Write capabilities, 512 bytes EEPROM, 512 bytes SRAM, an External memory

interface, 35 general purpose I/O lines, 32 general purpose working registers, two flexible Timer/Counters

with compare modes, Internal and External interrupts, a Serial Programmable USART, a programmable

Watchdog Timer with internal Oscillator, a SPI serial port, and three software selectable power saving

Page 21: RTC using ghraphical LCD 2003

modes. The Idle mode stops the CPU while allowing the SRAM, Timer/Counters, SPI port, and Interrupt

system to continue functioning. The Power-down mode saves the Register contents but freezes the

Oscillator, disabling all other chip functions until the next interrupt or hardware reset. In Standby mode, the

crystal/resonator Oscillator is running while the rest of the device is sleeping. This allows very fast start-up

combined with low-power consumption.

The device is manufactured using Atmel’s high density nonvolatile memory technology. The

On-chip ISP Flash allows the Program memory to be reprogrammed In-System through an SPI serial

interface, by a conventional nonvolatile memory programmer, or by an On-chip Boot program running on

the AVR core. The boot program can use any interface to download the application program in the

Application Flash memory. Software in the Boot Flash section will continue to run while the Application

Flash section is updated, providing true Read-While-Write operation. By combining an 8-bit RISC CPU

with In-System Self-programmable Flash on a monolithic chip, the Atmel ATmega8515 is a powerful

microcontroller that provides a highly flexible and cost effective solution to many embedded control

applications.

The ATmega8515 is supported with a full suite of program and system development tools

including: C Compilers, Macro assemblers, Program debugger/simulators, In-circuit Emulators, and

Evaluation kits.

Typical values contained in this datasheet are based on simulations and characterization of

other AVR microcontrollers manufactured on the same process technology. Min and Max values will be

available after the device is characterized.

2.4 PIN DESCRIPTIONS:

VCC:

Digital supply voltage

GND:

Ground

Port A (PA7...PA0):

Port A is an 8-bit bi-directional I/O port with internal pull-up resistors (selected for each bit).

The Port A output buffers have symmetrical drive characteristics with both high sink and source capability.

Page 22: RTC using ghraphical LCD 2003

When pins PA0 to PA7 are used as inputs and are externally pulled low, they will source current if the

internal pull-up resistors are activated. The PortA pins are tri-stated when a reset condition becomes active,

even if the clock is not running.

Port B (PB7...PB0):

Port B is an 8-bit bi-directional I/O port with internal pull-up resistors (selected for each bit).

The Port B output buffers have symmetrical drive characteristics with both high sink and source capability.

As inputs, Port B pins that are externally pulled low will source current if the pull-up resistors are activated.

The Port B pins are tri-stated when a reset condition becomes active, even if the clock is not running.

Port C (PC7...PC0):

Port C is an 8-bit bi-directional I/O port with internal pull-up resistors (selected for each bit).

The Port C output buffers have symmetrical drive characteristics with both high sink and source capability.

As inputs, Port C pins that are externally pulled low will source current if the pull-up resistors are activated.

The Port C pins are tri-stated when a reset condition becomes active, even if the clock is not running.

Port D (PD7...PD0):

Port D is an 8-bit bi-directional I/O port with internal pull-up resistors (selected for each bit).

The Port D output buffers have symmetrical drive characteristics with both high sink and source capability.

As inputs, Port D pins that are externally pulled low will source current if the pull-up resistors are activated.

The Port D pins are tri-stated when a reset condition becomes active, even if the clock is not running.

Port E (PE2...PE0):

Port E is a 3-bit bi-directional I/O port with internal pull-up resistors (selected for each bit).

The Port E output buffers have symmetrical drive characteristics with both high sink and source capability.

As inputs, Port E pins that are externally pulled low will source current if the pull-up resistors are activated.

The Port E pins are tri-stated when a reset condition becomes active, even if the clock is not running.

RESET Bar:

Reset input. A low level on this pin for longer than the minimum pulse length will generate a

reset, even if the clock is not running. The minimum pulse length is given in Table 18 on page 46. Shorter

pulses are not guaranteed to generate a reset.

XTAL1:

Input to the inverting Oscillator amplifier and input to the internal clock operating circuit.

Page 23: RTC using ghraphical LCD 2003

XTAL2:

Output from the inverting Oscillator amplifier

2.5 OSCILLATOR CHARACTERISTICS:

XTAL1 and XTAL2 are the input and output, respectively, of an inverting amplifier which can be

configured for use as an on-chip oscillator, as shown in Figure 2.1.6-1. Either a quartz crystal or ceramic

resonant or may be used. To drive the device from an external clock source, XTAL2 should be left

unconnected while XTAL1 is driven as shown in Figure 2.1.6-2. There are no requirements on the duty cycle

of the external clock signal, since the input to the internal clocking circuitry is through a divide-by-two flip-

flop, but minimum and maximum voltage high and low time specifications must be observed.

2.5.1 Oscillator Characteristics

Page 24: RTC using ghraphical LCD 2003

Oscillator Connections

Page 25: RTC using ghraphical LCD 2003

CHAPTER 3

DS1307

DS1307

3.1 FEATURES OF DS1307:

Page 26: RTC using ghraphical LCD 2003

Real-time clock (RTC) counts seconds, minutes, hours, date of the month, month,

day of the week, and year with leap-year compensation valid up to 2100.

56-byte, battery-backed, nonvolatile (NV) RAM for data storage.

Two-wire serial interface.

Programmable square wave output signal.

Automatic power-fail detects and switches circuitry.

Consumes less than 500nA in battery backup mode with oscillator running.

Optional industrial temperature range: 40°C to +85°C

Available in 8-pin DIP or SOIC.

Underwriters Laboratory (UL) recognized.

3.2 PIN DESCRIPTION:

VCC : Primary Power Supply

X1 X 2 : 32.768 kHz Crystal Connection

VBAT : +3V Battery Input

GND : Ground

SDA : Serial Data

SCL : Serial Clock

SQW/OUT : Square Wave/Output Driver

DESCRIPTION:

The DS1307 Serial Real-Time Clock is a low-power; full binary-coded decimal (BCD)

clock/calendar plus 56 bytes of NV SRAM. Address and data are transferred serially via a 2-wire, bi-

directional bus. The clock/calendar provides seconds, minutes, hours, day, date, month, and year

information. The end of the month date is automatically adjusted for months with fewer than 31 days,

including corrections for leap year. The clock operates in either the 24-hour or 12-hour format with AM/PM

indicator. The DS1307 has a built-in power sense circuit that detects power failures and automatically

switches to the battery supply.

3.3 TYPICAL OPERATING CIRCUIT:

Page 27: RTC using ghraphical LCD 2003

Fig 3.3.1 typical operating circuit of DS1307

OPERATION:

The DS1307 operates as a slave device on the serial bus. Access is obtained by

implementing a START condition and providing a device identification code followed by a register address.

Subsequent registers can be accessed sequentially until a STOP condition is executed. When VCC falls

below 1.25 x VBAT the device terminates an access in progress and resets the device address counter.

Inputs to the device will not be recognized at this time to prevent erroneous data from being written to the

device from an out of tolerance system. When VCC falls below VBAT the device switches into a low-

current battery backup mode. Upon power-up, the device switches from battery to VCC when VCC is

greater than VBAT + 0.2V and recognizes inputs when VCC is greater than 1.25 x VBAT. The above

diagram shows the main elements of the serial RTC.

3.4 DS1307 BLOCK DIAGRAM:

Page 28: RTC using ghraphical LCD 2003

Figure: 3.4.1 Block diagram of DS1307

3.5 SIGNAL DESCRIPTIONS:

VCC, GND:

DC power is provided to the device on these pins. VCC is the +5V input. When 5V is applied

within normal limits, the device is fully accessible and data can be written and read. When a 3V battery is

connected to the device and VCC is below 1.25 x VBAT, reads and writes are inhibited. However, the

timekeeping function continues unaffected by the lower input voltage. As VCC falls below VBAT the RAM

and timekeeper are switched over to the external power supply (nominal 3.0V DC) at VBAT.

VBAT:

Battery input for any standard 3V lithium cell or other energy source. Battery voltage must be

held between 2.0V and 3.5V for proper operation. The nominal write protect trip point voltage at which

access to the RTC and user RAM is denied is set by the internal circuitry as 1.25 x VBAT nominal. A

lithium battery with 48mAhr or greater will back up the DS1307 for more than 10 years in the absence of

power at 25ºC. UL recognized to ensure against reverse charging current when used in conjunction with a

Lithium battery.

SCL (Serial Clock Input):

SCL is used to synchronize data movement on the serial interface.

SDA (Serial Data Input/Output):

Page 29: RTC using ghraphical LCD 2003

SDA is the input/output pin for the 2-wire serial interface. The SDA pin is open drain which

requires an external pull up resistor.

SQW/OUT (Square Wave/Output Driver):

When enabled, the SQWE bit set to 1, the SQW/OUT pin outputs one of four square wave

frequencies (1Hz, 4 kHz, 8 kHz, 32 kHz). The SQW/OUT pin is open drain and requires an external pull-up

resistor. SQW/OUT will operate with either Vcc or Vbat applied.

X1 X2:

Connections for a standard 32.768 kHz quartz crystal. The internal oscillator circuitry is designed

for operation with a crystal having a specified load capacitance (CL) of 12.5pF.

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.

External circuit noise coupled into the oscillator circuit may result in the clock running fast.

RTC AND RAM ADDRESS MAP:

The address map for the RTC and RAM registers of the DS1307 is shown below. The RTC

registers are located in address locations 00h to 07h. The RAM registers are located in address locations 08h

to 3Fh. During a multi-byte access, when the address pointer reaches 3Fh, the end of RAM space, it wraps

around to location 0 the beginning of the clock.

Page 30: RTC using ghraphical LCD 2003

CLOCK AND CALENDAR:

The time and calendar information is obtained by reading the appropriate register bytes.

The RTC registers are illustrated in the below figure. The time and calendar are set or initialized

by writing the appropriate register bytes. The contents of the time and calendar registers are in the BCD

format. Bit 7 of register 0 is the clock halt (CH) bit. When this bit is set to a 1, the oscillator is disabled.

When cleared to a 0, the oscillator is enabled.

The DS1307 can be run in either 12-hour or 24-hour mode. Bit 6 of the hours register is defined

as the 12- or 24-hour mode select bit. When high, the 12-hour mode is selected. In the 12-hour mode, bit 5

is the AM/PM bit with logic high being PM. In the 24-hour mode, bit 5 is the second 10 hour bit (20- 23

hours).

On a 2-wire START, the current time is transferred to a second set of registers. The time

information is read from these secondary registers, while the clock may continue to run. This eliminates the

need to reread the registers in case of an update of the main registers during a read.

3.5 DS1307 TIMEKEEPER REGISTERS:

3.6 CONTROL REGISTER:

The DS1307 control register is used to control the operation of the SQW/OUT pin.

Table time keeper and control registers

OUT (Output control):

Page 31: RTC using ghraphical LCD 2003

This bit controls the output level of the SQW/OUT pin when the square wave output is disabled. If

SQWE = 0, the logic level on the SQW/OUT pin is 1 if OUT = 1 and is 0 if OUT = 0.

SQWE (Square Wave Enable):

This bit, when set to logic 1, will enable the oscillator output. The frequency of the square wave

output depends upon the value of the RS0 and RS1 bits. With the square wave output set to 1Hz, the clock

registers update on the falling edge of the square wave.

RS (Rate Select):

These bits control the frequency of the square wave output when the square wave output has been

enabled. Table below lists the square wave frequencies that can be selected with the RS bits.

SQUAREWAVE OUTPUT FREQUENCY:

3.7 2-WIRE SERIAL DATA BUS:

The DS1307 supports a bi-directional, 2-wire bus and data transmission protocol. A device that

sends data onto the bus is defined as a transmitter and a device receiving data as a receiver. The device that

controls the message is called a master. The devices that are controlled by the master are referred to as

slaves. The bus must be controlled by a master device that generates the serial clock (SCL), controls the bus

access, and generates the START and STOP conditions. The DS1307 operates as a slave on the 2-wire bus.

A typical bus configuration using this 2-wire protocol is show in Figure below.

3.8 TYPICAL 2-WIRE BUS CONFIGURATION:

Page 32: RTC using ghraphical LCD 2003

Fig .3.8.1 2-wire bus configuration

Data transfer may be initiated only when the bus is not busy.

During data transfer, the data line must remain stable whenever the clock line is HIGH. Changes in

the data line while the clock line is high will be interpreted as control signals.

Accordingly, the following bus conditions have been defined:

BUS NOT BUSY:

Both data and clock lines remain HIGH.

START DATA TRANSFER:

A change in the state of the data line, from HIGH to LOW, while the clock is HIGH, defines a

START condition.

STOP DATA TRANSFER:

A change in the state of the data line, from LOW to HIGH, while the clock line is HIGH, defines

the STOP condition.

DATA VALID:

The state of the data line represents valid data when, after a START condition, the data line is

stable for the duration of the HIGH period of the clock signal. The data on the line must be changed during

the LOW period of the clock signal. There is one clock pulse per bit of data.

Each data transfer is initiated with a START condition and terminated with a STOP condition.

The number of data bytes transferred between START and STOP conditions is not limited, and is

determined by the master device. The information is transferred byte-wise and each receiver acknowledges

with a ninth bit. Within the 2-wire bus specifications a regular mode (100 kHz clock rate) and a fast mode

(400 kHz clock rate) are defined. The DS1307 operates in the regular mode (100 kHz) only.

Page 33: RTC using ghraphical LCD 2003

3.9 DATA TRANSFER ON 2-WIRE SERIAL BUS:

Fig 3.9.1 Data transfer on 2-wire serial bus

Depending upon the state of the R/W bit, two types of data transfer are possible:

Data transfer from a master transmitter to a slave receiver:

The first byte transmitted by the master is the slave address. Next follows a number of data

bytes. The slave returns an acknowledge bit after each received byte. Data is transferred with the most

significant bit (MSB) first.

Data transfer from a slave transmitter to a master receiver:

The first byte (the slave address) is transmitted by the master. The slave then returns an

acknowledge bit. This is followed by the slave transmitting a number of data bytes. The master returns an

acknowledge bit after all received bytes other than the last byte. At the end of the last received byte, a “not

acknowledge” is returned. The master device generates all of the serial clock pulses and the START and

STOP conditions. A transfer is ended with a STOP condition or with a repeated START condition. Since a

repeated START condition is also the beginning of the next serial transfer, the bus will not be released. Data

is transferred with the most significant bit (MSB) first.

The DS1307 may operate in the following two modes:

Slave receiver mode (DS1307 write mode):

Page 34: RTC using ghraphical LCD 2003

Serial data and clock are received through SDA and SCL. After each byte is received an

acknowledge bit is transmitted. START and STOP conditions are recognized as the beginning and end of a

serial transfer. Address recognition is performed by hardware after reception of the slave address and

*direction bit. The address byte is the first byte received after the start condition is generated by the master.

The address byte contains the 7 bit DS1307 address, which is 1101000, followed by the *direction bit (R/W)

which, for a write, is a 0. After receiving and decoding the address byte the device outputs an acknowledge

on the SDA line. After the DS1307 acknowledges the slave address + write bit, the master transmits a

register address to the DS1307. This will set the register pointer on the DS1307. The master will then begin

transmitting each byte of data with the DS1307 acknowledging each byte received. The master will generate

a stop condition to terminate the data write.

3.10 DATA WRITE – SLAVE RECEIVER MODE:

Slave transmitter mode (DS1307 read mode):

The first byte is received and handled as in the slave receiver mode. However, in this mode, the

*direction bit will indicate that the transfer direction is reversed. Serial data is transmitted on SDA by the

DS1307 while the serial clock is input on SCL. START and STOP conditions are recognized as the

beginning and end of a serial transfer .The address byte is the first byte received after the start condition is

generated by the master. The address byte contains the 7-bit DS1307 address, which is 1101000, followed

by the *direction bit (R/W) which, for a read, is a 1. After receiving and decoding the address byte the

device inputs an acknowledge on the SDA line. The DS1307 then begins to transmit data starting with the

register address pointed to by the register pointer. If the register pointer is not written to before the initiation

Page 35: RTC using ghraphical LCD 2003

of a read mode the first address that is read is the last one stored in the register pointer. The DS1307 must

receive a “not acknowledge” to end a read.

3.10.1DATA READ – SLAVE TRANSMITTER MODE:

CHAPTER 4

GRAPHICAL LCD

Page 36: RTC using ghraphical LCD 2003

GRAPHICAL LCD

4.1 INTRODUCTION

A liquid crystal display (LCD) is a thin, flat panel used for electronically

displaying information such as text, images, and moving pictures. ...

128X64 GRAPHICAL LCD PICTURE:

Page 37: RTC using ghraphical LCD 2003

Figure: 4.1.1 Picture of graphical LCD

4.2 A MAP OF LCD PIXELS:

Fig 4.2.1 map of LCD pixels

4.3 PIN DESCRIPTION:

Page 38: RTC using ghraphical LCD 2003

Table 4.3.1 Pin description of graphical LCD

4.4 DISPLAY CONTROL INSTRUCTION:

Page 39: RTC using ghraphical LCD 2003

There are two ways to interface the LCD with microcontroller:

1. Address/data bus memory map, i.e. use the LCD as a piece of external RAM

2. Direct I/O connection by writing high/low signal to LCD.

Because there are a lot of other microcontrollers that don’t have address/data bus system, we

will use method 2 for now so this driver could be easily ported to other microcontrollers in future. The first

task is to understand the control sequence required to read or write data to the LCD module. Below figure

shows the DISPLAY CONTROL INSTRUCTION extracted from its controller’s data sheet (KS0108).

Table display control Instruction

There are several points to watch out:

1. RS is equivalent to PIN D/I as stated on JHD12864J data sheet. It controls data or command action

(D/I=LOW _ command; D/I=HIGH _ data).

2. Horizontal pixel addressed by Y address counter (0-63). The nomenclature is not the same as our

convention of Cartesian coordinate system (x-y) learned in secondary school. The Y address indicates the

column position in the horizontal direction. Why only 64 pixels but not 128 pixels? Because the LCD is

splitted logically in half with controller #1 (CS1) driving the left half of the display, and controller #2 (CS2)

driving the right half. We need to handle each half individually.

Page 40: RTC using ghraphical LCD 2003

3. The term Page refers to 8-pixel vertically. There are 8 pages ranging from 0 to 7, thus matching a vertical

matrix size of 64 pixels. Refer to Figure 8.1.2 for illustration.

4. R/W controls data READ/WRITE (R/W=LOW _ write; R/W=HIGH _ read). The reason of writing bytes

to the LCD is obvious: we need to display something on the LCD. However, being capable of reading from

the module is also important because it is only possible to write to a whole Page in 8-bit format. As an

example, we want to display a single pixel at the 10th column on 3rd pixel down the top Page where there is

an existing byte 0xAB. If we simply output 0x40 (0b0000 0100), the byte pattern 0xAB would be erased.

One possible way is to perform a data read first, store the byte in background to a temporary variable, and

do a bitwise OR operation with 0x40. This makes a new byte value of 0xAF. The whole procedure is

illustrated below.

Page 41: RTC using ghraphical LCD 2003

CHAPTER 5

POWER SUPPLY

Page 42: RTC using ghraphical LCD 2003

POWER SUPPLY

In-order to work with any components basic requirement is power supply. In this section there is a

requirement of two different voltage levels.

Those are

1)5V DC power supply.

Now the aim is to design the power supply section which converts 230V AC in to 5V DC.

Since 230V AC is too high to reduce it to directly 5V DC, therefore we need a step-down transformer that

reduces the line voltage to certain voltage that will help us to convert it in to a 5V DC. Considering the

efficiency factor of the bridge rectifier, we came to a conclusion to choose a transformer, whose secondary

voltage is 3 to 4 V higher than the required voltage i.e. 5V. For this application 0-9V transformers is used,

since it is easily available in the market.

The output of the transformer is 9V AC; it feed to rectifier that converts AC to pulsating DC. As we all

know that there are 3 kind of rectifiers that is

1. half wave

2. Full wave and

3. Bridge rectifier

Here we short listed to use Bridge rectifier, because half wave rectifier has we less in efficiency. Even

though the efficiency of full wave and bridge rectifier are the same, since there is no requirement for any

negative voltage for our application, we gone with bridge rectifier.

Since the output voltage of the rectifier is pulsating DC, in order to convert it into pure DC we use a high

value (1000UF/1500UF) of capacitor in parallel that acts as a filter. The most easy way to regulate this

voltage is by using a 7805 voltage regulator, whose output voltage is constant 5V DC irrespective of any

fluctuation in line voltage.

Page 43: RTC using ghraphical LCD 2003

CHAPTER 6

AND

Page 44: RTC using ghraphical LCD 2003

SCHEMATIC DIAGRAM

V C C

E N

P B 1

GND1 0 K

P B 6

1 0 4 p f

PA 5

PA 0PC3

S W 1

S W 5

V C C

P D 4

GND

S W 2

P C 7

D B 2

V C C

S W 1

D B 6

P B 5

TR A N S F O R M E R

1 5

4 8

GND

V C C

3 V B A TTE R Y

S D A

2 2 p f

C S 1

GND

S C L

I

S W 8

P B 4

XTA L 2

V C C

1 0 K P U L L U P

XTA L 1

PA 2

PC1

PC5

S W 7

S W 4

- +

B R I D G E R E C TI F I E R

P D 6

GND

D B 1

S

XTA L 2

D B 5

S W 8

22

0 o

hm

V C C

GND

2 2 K

P

V C C

V C C

PC6

C S 2

S W 3

3 2 . 7 6 8 K H Z

O / I

S W 5

GND

P C 0

P B 3

5 K

GND

LE

D

F R O M I S P (2 )

PC2

VCC

R1

R2

R3

R4

R7

R6

R5

R8

1 0 K P U L L U P

987654321

F R O M I S P (1 0 )

PA 7

8 . 0 0 0 M H z

2 3 0 V A . C

12

GND

G N D

1 23 45 67 89 1 0

S W 7

VSSVDDV0D/IR/WENDB0DB1DB2DB3DB4DB5DB6DB7CS1CS2RSTVEELED+LED-

G R A P H I C A L L C D

123456789

1 01 11 21 31 41 51 61 71 81 92 0

R E S E T

2

S W 3

V C C

P D 5

7 8 0 5 R E G U L A TO R1 3

V I N V O U T

GND

D B 4

D B 0

R S T

(9V/1 AMP)

P B 7

X1X2VBATGND SDA

SCLSQWVCC

D S1 3 0 7

1234

8765

PC4

1 0 K P U L L U P

POW ER SU PPL Y(5 VD C )

1 0 K

R / W

P B 2

1 0 0 0 u f / 3 5 v

3 3 p f

R8

R7

R6

R5

R4

R1

R2

R3

VCC

1 2 3 4 5 6 7 8 9

XTA L 1

S W 6

S W 1

PA 4PA 3

0 . 1 u f / 3 5 V

ATMEGA8 5 1 5 ISP

S W 2

R8

R7

R6

R5

R4

R1

R2

R3

VCC

1 2 3 4 5 6 7 8 9

P D 3

V C C

R E S E T

D B 3

F R O M I S P (4 )

S W 6

PA 6

ATMEGA8 5 1 5 C R YSTAL

D B 7

3 3 0 o h m s

3 3 0 o h m s

F R O M I S P (6 )R E S E T

S W 4

ATMEGA8 5 1 5 L

9

1 8

1 9

2 9

3 0

3 13 2

1 01 11 21 31 41 51 61 7

4 03 93 83 73 63 53 43 3

2 82 72 62 52 42 32 22 1

12345678

2 0

R E S E T

XTA L 2

XTA L 1

P E 2 (O C 1 B )

P E 1 (A L E )

P E 0 (I C P / I N T2 )P A 7 / A D 7

(R XD ) P D 0(TD X) P D 1(I N T0 ) P D 2(I N T1 ) P D 3(XC K ) P D 4(O C 1 A ) P D 5(W R ) P D 6(R D ) P D 7

V C CP A 0 / A D 0P A 1 / A D 1P A 2 / A D 2P A 3 / A D 3P A 4 / A D 4P A 5 / A D 5P A 6 / A D 6

P C 7 (A 1 5 )P C 6 (A 1 4 )P C 5 (A 1 3 )P C 4 (A 1 2 )P C 3 (A 1 1 )P C 2 (A 1 0 )

P C 1 (A 9 )P C 0 (A 8 )

(O C 0 / T0 ) P B 0(T1 ) P B 1(A I N 0 ) P B 2(A I N 1 ) P B 3(S S ) P B 4(M O S I ) P B 5(M I S O ) P B 6(S C K ) P B 7

G N D

2 2 p f

PA 1

R ESET

Fig 6.1.1 schematic diagram of RTC using graphical LCD

Page 45: RTC using ghraphical LCD 2003

CODING

/**HEADER FILES**/

#include <mega8515.h>

#include <i2c.h>

#include <stdio.h>

#include <delay.h>

#include <string.h>

/**I2C PIN CONNECTIONS**/

#asm

.equ __i2c_port=0x15

.equ __sda_bit=0

.equ __scl_bit=7

#endasm

//DEFINING DEVICE ADDRESS

#define RTC_BUS_ADDRESS 0xD0

/**GLCD PIN CONNECTIONS**/

#define RS PORTC.1

#define IO PORTC.2 //R&W pin

#define LCD_EN PORTC.3

#define RST PORTC.6

#define CS1 PORTC.4

#define CS2 PORTC.5

#define bus PORTA

/**SWITCH CONNECTIONS**/

#define SEL PIND.3

#define INC PIND.4

#define DEC PIND.5

#define EXIT PIND.6

Page 46: RTC using ghraphical LCD 2003

#define sw1 PINB.1

#define sw2 PINB.2

#define sw3 PINB.3

#define sw4 PINB.4

/**GRAPHICAL LCD FUNCTIONS DECLARATION**/

void glcd_init(void);

void busy_check(void);

void writecmd(unsigned char);

void writedata(unsigned char);

void clear_display(void);

void pageclear(void);

void display_lcd(void);

void graph0(void);

void graph1(void);

void graph2(void);

void graph3(void);

/**RTC FUNCTIONS DECLARATION**/

void edit_hr(void);

void edit_min(void);

void edit_date(void);

void edit_month(void);

void edit_year(void);

unsigned char rtc_read(unsigned char);

void rtc_write(unsigned char, unsigned char);

unsigned char Time[22][6];

/**VARIABLES INITIALIZATION**/

unsigned char flash charset[27][6] = {

{0x3e,0x51,0x49,0x45,0x3e,0}, //0

Page 47: RTC using ghraphical LCD 2003

{0x04,0x42,0x7f,0x40,0x00,0}, //1

{0x42,0x61,0x51,0x49,0x46,0}, //2

{0x21,0x41,0x45,0x4b,0x31,0}, //3

{0x18,0x14,0x12,0x7f,0x10,0}, //4

{0x27,0x45,0x45,0x45,0x39,0}, //5

{0x3c,0x4a,0x49,0x49,0x30,0}, //6

{0x01,0x71,0x09,0x05,0x03,0}, //7

{0x36,0x49,0x49,0x49,0x36,0}, //8

{0x06,0x49,0x49,0x29,0x1e,0}, //9

{0x20,0x36,0x36,0x00,0x00,0}, // ':'10

{0x20,0x10,0x08,0x04,0x02,0}, // '/'11

{0x00,0x00,0x00,0x00,0x00,0}, // ' '12

{0x01,0x01,0x7F,0x01,0x01,0}, // 'T'13

{0x41,0x41,0x7F,0x41,0x41,0}, // 'I'14

{0x7F,0x02,0x0C,0x02,0x7F,0}, // 'M'15

{0x7F,0x49,0x49,0x49,0x41,0}, // 'E'16

{0x7f,0x41,0x41,0x22,0x1c,0}, //'D'17

{0x7f,0x08,0x04,0x04,0x78,0}, //'h'18

{0x38,0x44,0x44,0x44,0x38,0}, //'o'19

{0x3c,0x40,0x40,0x20,0x7c,0}, //'u'20

{0x7c,0x08,0x04,0x04,0x00,0}, //'r'21

{0xF8,0x08,0x10,0x08,0xF0,0}, //'m'22

{0x80,0x88,0xFA,0x80,0x80,0}, //'i'23

{0xF8,0x10,0x08,0x08,0xF0,0}, //'n'24

{0x90,0xA8,0xA8,0xA8,0x40,0}, //'s'25

{0x07,0x08,0x70,0x08,0x07,0} //'Y'26

};

/** HOUSE **/

unsigned char const arr0[8][128] =

{

{

0, 0, 0, 0, 4, 10, 58, 62,122,210,208,208,208,208,208, 48,

188, 60,172,172,246,247,255,110,254,190,126,126, 92,152, 96, 0,

Page 48: RTC using ghraphical LCD 2003

0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,

0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,

128,128,128,128, 0,129,129,141,143,136,192, 80,208,200, 8, 8,

140, 12, 58, 58, 71,130,135, 0,161,208,112,240,160,166,166,153,

139,142,141,143, 15, 27, 23, 23, 27, 15, 15,143,190,187,191,159,

204,140,143,246,246,246,230,189,255,177,189,238,195, 76, 0, 0},

{

0, 0, 0, 0, 0, 0, 0, 24, 28,222,126,123, 57, 63,125,120,

15, 15, 3, 3, 65,193,225,193,192,192, 0, 0, 0, 0, 0, 0,

0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,

0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 98, 99, 29,

153,192, 66,199,132,132,133,135, 0, 0,128, 80,120, 81,113,118,

126, 63, 31, 22,227,253,248,224,192,193,194,194,194,195,129, 0,

1,131,131,191,191,230,234,234,188,248,241,195, 66, 71,129,133,

133,174,255,255,247,255,255,254,254,255,251,253,210,208, 0, 0},

{

0, 0, 0, 0, 32, 60, 52,247,254,241,245,239,255,188,182,254,

252,230,243,233,247,151,153,255,247,243,223,221,252,120,120,248,

104,120,248,112,112, 48, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16,

16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16,

16, 16, 16, 16, 16, 16, 16, 17, 17, 17, 17, 16, 16, 16, 16, 16,

16, 16, 16, 16, 31, 31, 31, 31, 17, 17, 17, 17, 17, 17, 17, 18,

18, 25, 25, 44, 15, 31, 63, 63,111,127, 58, 63,119,119,255,191,

53, 22, 31, 11, 31, 31, 47, 63, 63,255,207,255,255, 47, 37, 0},

{

0, 0, 0, 0, 0, 0, 32,251,255,255,255,255,255,131,129,193,

227,227, 51, 55,229,199, 7, 15, 11, 27, 31, 28, 56,240, 96, 96,

97, 97, 97, 97, 96, 96, 96, 96, 96, 96, 96, 96, 96, 96, 96, 96,

96, 96, 96, 96, 96, 96,224, 96, 96, 96, 96, 96, 96, 96, 96, 96,

96, 96, 96, 96, 96, 96, 96, 96, 96, 96, 96, 96, 96, 96, 96, 96,

96, 96, 96, 96, 96, 96, 96, 96, 96, 96, 96, 96, 96, 96, 96, 96,

96, 96, 96, 96, 96, 96, 96, 96, 96, 96, 96, 96, 96, 96, 96, 97,

99, 98,102,108,248,240, 96, 96, 0,255,255,255,255, 0, 0, 0},

{

Page 49: RTC using ghraphical LCD 2003

0, 0, 0, 0, 2, 23, 29, 33, 33,255,255,255,255,167,167, 58,

24,120,248,232,121,123,122,158,144, 0,252,158,159,127, 96,128,

14, 10, 10, 10, 10, 10, 10, 14, 0, 0, 0, 14, 10, 10, 10, 10,

10, 14, 14, 0, 0,128,255,248,232,192,192,254,254,254, 34, 34,

34, 34, 34, 34,254, 34, 34, 34, 34, 34, 34, 34,254,254,254, 50,

0, 0, 0,254,130,186, 58, 58, 98, 98, 98, 98, 2,254, 0, 0,

0,254,254,254,254, 34, 34, 34, 34,254,254, 34, 34, 34, 34, 34,

254,254,254,224,127,255,194,222,126,255,255,255,255, 0, 0, 0},

{

0, 0, 0, 0, 0,128,128,128, 96,191,255,127,255,255,225,195,

207,140,137, 8, 8, 8, 8, 25, 63, 59, 11, 79, 79, 73,233,254,

168,160,160, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32,

32, 32, 32, 32, 60, 63, 39, 47, 63, 63,125, 73, 9,225, 64, 72,

120,120,120,121, 73, 65, 77, 81, 25,121, 73,121, 49,113, 73, 73,

200,200,120,127, 80, 81, 64, 64, 64, 80, 80,240,224,127, 24,152,

144,201,233,249,249, 56,136, 8,144,241,121,120,160,248,240,112,

9,121, 63,127,120,104, 77, 76,124,255,255,255,255,248, 0, 0},

{

0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,

0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,

1, 1, 3, 3, 3, 6, 6, 12, 12, 24, 24, 16, 48, 32, 96, 96,

192,192,128,128, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 0, 2,

2, 6, 6, 0, 0, 4, 0, 0, 2, 2, 34, 98, 98,208,209,145,

145, 16, 16, 16, 8, 8, 8, 4, 6, 2, 1, 1, 0, 0, 0, 0,

0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,

0, 0,128,128,192,192,224,224,248,231,239,255,119, 67, 0, 0},

{

0, 0, 0, 0, 0, 0, 0,128,128, 0,192,192,192,192,192,192,

192,192,192,192,192,192,192,192,192,192,192,192,192, 64, 64, 64,

64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 96,

64, 64, 65, 65, 99, 99, 98,102,102,108,108,120,120,120,112,112,

32, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1,

1, 1, 3, 2, 6, 6, 12, 12, 24, 24, 48, 48, 48, 48, 48, 48,

48, 48, 48, 48, 48, 48, 48, 48, 48, 48, 48, 48, 48, 48, 48, 48,

Page 50: RTC using ghraphical LCD 2003

48, 48, 48, 48, 48, 48, 48, 48, 16, 16, 0, 0, 0, 0, 0, 0}

};

//COLLEGE NAME

unsigned char const arr1[8][128] =

{

{

255,255, 15, 7, 3,131,143, 19, 35, 67,131, 3, 3, 3, 3, 3,

3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 35,227,227, 3, 35, 35,

227,227, 35, 3, 35,227, 35, 35,227,227, 35, 35, 35, 99, 3, 3,

35,227,227, 35, 3, 3, 3, 3, 3, 3,131,195, 99, 35, 35, 67,

227, 3, 3, 3,131,195, 99, 35, 35, 99,195,131, 3, 35,227,227,

227, 3, 3, 3,227,227,227, 35, 3, 3, 35,227,227, 35, 35, 35,

99, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3,

3, 3, 3, 3, 3,131, 67, 35, 19,143,131, 3, 7, 15,255,255},

{

255,255, 0, 78,145, 36,164, 35, 16, 72,135, 16, 0, 0, 0, 0,

0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 7, 63, 56, 6,

1, 7, 62, 56, 6, 1, 0, 32, 63, 63, 34, 39, 32, 48, 0, 0,

32, 63, 63, 32, 32, 48, 60, 0, 0, 0, 15, 31, 48, 32, 32, 32,

16, 0, 0, 0, 15, 31, 48, 32, 32, 48, 31, 15, 0, 32, 63, 32,

7, 63, 56, 7, 32, 63, 63, 32, 0, 0, 32, 63, 63, 34, 39, 32,

48, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,

0, 0, 0, 0, 16,135, 72, 16, 35,164, 36,145, 78, 0,255,255},

{

255,255, 0,128,192,192,128, 1, 0, 0, 0, 0, 0, 0, 0, 0,

0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,

0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,

0, 0, 0, 0, 0, 24, 8, 8,248,248, 8, 8, 24, 0, 0,224,

240, 24, 8, 8, 24,240,224, 0, 0, 0, 0, 0, 0, 0, 0, 0,

0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,

0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,

0, 0, 0, 0, 0, 0, 0, 0, 1,128,192,192,128, 0,255,255},

{

Page 51: RTC using ghraphical LCD 2003

255,255, 0, 1, 3, 3, 1, 0, 0,128,128, 0, 0, 0, 0,128,

128,128,128,128,128,128,128,128,128,128,128,128,128,128,128, 0,

0, 0, 0,128,128,128,128,128,128,128,128,128, 0, 0, 0, 0,

128,128,128,128,128,128,128,136,143, 15,136,128,128,128,128,131,

135,140,136,136,140,135,131,128,128,128,128,128, 0, 0, 0, 0,

0, 0, 0,128,128,128,128,128,128,128,128,128, 0,128,128,128,

128,128,128,128,128,128,128,128,128,128,128,128,128,128,128,128,

0, 0, 0, 0, 0,128,128, 0, 0, 1, 3, 3, 1, 0,255,255},

{

255,255, 0, 0, 0, 0, 0, 0, 3, 7, 7, 3, 0, 0, 0, 0,

0, 0,255,255,255,255,255, 0, 0, 0, 0, 1,131,255,255,255,

126, 56, 0, 0, 1, 7, 31,255,255,255,248,192, 0, 0, 0, 0,

192,248,255,255,255, 31, 7, 1, 0, 0, 0, 0, 0,255,255,255,

255,255, 1, 1, 1, 1, 1, 1, 3,255,255,255,255,126, 0, 0,

0, 0, 0, 0, 0,255,255,255,255,255, 0, 0, 0, 31, 7, 1,

0, 0, 0, 0,255,255,255,255,255, 0, 0, 0, 0, 1, 7, 31,

0, 0, 0, 0, 3, 7, 7, 3, 0, 0, 0, 0, 0, 0,255,255},

{

255,255, 0, 12, 30, 30, 12, 0, 0, 0, 0, 0, 0, 0, 0, 0,

0, 0,255,255,255,255,255, 2, 2, 2, 2, 7, 15,255,253,252,

248,240,224, 0, 0, 0, 0, 0, 3, 15,127,255,255,248,248,255,

255,127, 15, 3, 0, 0, 0, 0, 0, 0, 0, 0, 0,255,255,255,

255,255, 12, 12, 12, 28,124,254,255,255,199,129, 0, 0, 0, 0,

0, 0, 0, 0, 0,255,255,255,255,255, 0, 0, 0, 0, 0, 0,

0, 0, 0, 0,255,255,255,255,255, 0, 0, 0, 0, 0, 0, 0,

0, 0, 0, 0, 0, 0, 0, 0, 0, 12, 30, 30, 12, 0,255,255},

{

255,255, 0, 0, 0, 0, 0, 0, 24, 60, 60, 24, 0, 0, 0, 16,

16, 16, 31, 31, 31,159, 95,144, 16, 16, 16, 24, 28, 31, 31, 15,

7,131, 65,128, 0, 0, 0, 0, 0, 0, 0, 1, 15,159, 95,143,

1, 0, 0, 0, 0, 0, 0, 0, 0,128, 80,144, 16, 31, 31, 31,

31, 31, 16, 16, 16,128, 64,128, 3, 7, 15, 31, 31, 30, 28, 24,

16,144, 64,144, 16, 31, 31, 31, 31, 31, 16, 16, 0,128, 64,128,

0, 16, 16, 16, 31, 31, 31, 31, 31,144, 80,144, 0, 0, 0, 0,

Page 52: RTC using ghraphical LCD 2003

0, 0, 0, 0, 24, 60, 60, 24, 0, 0, 0, 0, 0, 0,255,255},

{

255,255,224,216,252,252,216,192,192,192,192,192,192,192,224,224,

240,232,228,226,225,248,228,248,225,226,228,232,240,232,228,226,

225,248,228,248,225,226,228,232,240,232,228,226,225,248,228,248,

225,226,228,232,240,232,228,226,225,248,228,248,225,226,228,232,

240,232,228,226,225,248,228,248,225,226,228,232,240,232,228,226,

225,248,228,248,225,226,228,232,240,232,228,226,225,248,228,248,

225,226,228,232,240,232,228,226,225,248,228,248,225,226,228,232,

240,224,192,192,192,192,192,192,192,216,220,252,216,224,255,255}

};

//TAJ PICTURE

unsigned char const arr2[8][128] =

{

{

0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,

0, 0,156,255, 1, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1,

1, 1, 6, 8, 16, 8, 6, 2, 2, 3, 1, 1, 1, 3, 2, 2,

6, 4, 12, 24, 24, 24, 48, 16, 16, 48, 32, 32, 96, 64,192, 0,

0, 0, 0, 0, 0, 0, 0, 0, 0, 0,128, 64, 64, 96, 48, 24,

8, 12, 4, 8, 12, 4, 4, 24,144,240, 0, 0, 0,112,252, 2,

1, 1, 1, 1, 1, 1, 1, 2, 12, 8, 12, 4, 12, 8, 8, 12,

6, 2, 2, 2, 2, 2, 6, 28, 16, 16, 16, 16, 16, 48, 32, 32},

{

0, 0, 0, 0, 0, 0, 0, 0, 0,128,192,120, 12, 12, 4, 6,

3, 1, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,

0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,

0, 0, 0, 0, 0, 0, 0,128,240, 16, 16, 16, 24, 8, 13, 7,

0, 0, 0,128, 64,126,126, 64,134, 11, 8, 8, 24, 16, 16, 16,

16, 28, 4, 8, 8, 4, 4, 7,129,112, 16, 24, 8, 8, 13, 7,

2, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,

0,128,128,192, 64, 64, 64,128, 0,128,192, 64, 64, 64, 64, 64},

{

Page 53: RTC using ghraphical LCD 2003

0, 0, 0, 0, 0, 0, 0, 0, 0, 64, 64, 64,112, 16, 48, 32,

64, 64, 32, 48, 16, 8, 8, 8, 14,134,228,132, 8, 24, 8, 4,

4, 6, 3, 2, 6, 6, 12, 12, 8, 8, 8, 12, 8, 12, 6, 2,

2, 6, 6, 6, 2, 2, 2, 3, 0, 0, 0,128, 64, 32, 16, 8,

4, 2, 1, 0, 0, 0, 0, 0, 0, 1, 2, 4, 8, 16, 32, 64,

128, 0, 0, 0, 0, 0, 0, 0, 3, 6, 4, 12, 8, 24, 48, 32,

32, 32, 32, 24, 8, 12, 4, 4, 4, 4, 4, 4, 6, 2, 1,129,

225,129, 0, 0, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 0, 0},

{

0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,

0, 0, 0, 0, 0, 0, 0, 0,255, 92, 84, 92,255, 0, 0, 0,

0, 0, 0, 0,128,128, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,

0, 0, 0, 0, 0, 0,128,240,128,128,255,160,160,160,160,160,

160,160,160,160,160,160,160,160,160,160,160,160,160,160,160,160,

160,255,128,128,240,128, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,

0, 0, 0, 0, 0, 0,128,128, 0, 0, 0, 0, 0, 0,255, 44,

44, 44,255, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0},

{

0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,

0, 0, 0, 0, 0, 0, 0,128,255,128,128,128,255,128, 0, 0,

0, 0, 0,254, 27, 27,254, 0, 0, 0, 0, 0, 0,224, 32, 60,

224, 0, 0,248, 30, 17,144, 80, 80,145, 19, 30,210, 82, 82, 82,

82, 82, 82, 82, 82, 82, 82, 82, 82, 82, 82, 82, 82, 82, 82,222,

19, 17,144, 80, 80,144, 17, 30,252,128,128,240,156,144,240, 0,

0, 0, 0, 0, 0,254, 27, 27,254, 0, 0, 0, 0,192,255,192,

192,192,255,192, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0},

{

0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,

0, 0, 0, 0, 0, 0, 0, 1,255, 1, 1, 1,255, 1, 0, 0,

0, 0, 96,255, 96, 96,255, 96, 0, 0, 0, 0, 0,255, 1,113,

73,113, 1,255, 0,239, 40, 40, 40, 40,239, 0,255, 0,227, 19,

200, 36, 18, 10, 10,138, 10, 10, 18, 36,200, 16,227, 3, 0,255,

0,239, 40, 40, 40, 40,239, 0,255, 0, 56, 36, 56, 0,255, 0,

0, 0, 0, 0, 48,255, 48, 48,255, 48, 0, 0, 0, 0,255, 0,

Page 54: RTC using ghraphical LCD 2003

0, 0,255, 0,192, 64, 96, 32, 64, 32, 32,224,192,224,240, 48},

{

96,192,128, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,

0, 0, 0, 0, 0, 0, 0,254,255, 6, 6, 6,255,254,128,128,

192, 0,240,255, 48, 48,255,240, 0, 0, 0, 0, 0,255, 0,158,

82,158, 0,255, 0,199,100, 52,100,196, 7, 0,255, 0,255, 0,

255, 0, 0,254, 3, 1, 3,254, 0, 0,255, 0,255, 0, 0,255,

0,135, 68, 52, 52, 68,199, 0,255, 0,143, 73,143, 0,255, 0,

0, 0, 0, 0,240,255, 48, 48,255,240, 0, 0, 0,254,255, 6,

6, 6,255,254, 1,112, 24,224,176, 24, 8, 0,131,243, 0, 0},

{

48, 96,193, 2, 6,136,140, 8, 8,248, 96, 48,184, 88,140, 4,

12,152,240, 96, 64, 64,192,255,255,225,193,193,193, 64, 64, 64,

67, 68, 71, 95, 88, 88, 95, 95, 88, 88, 88, 88, 88, 95, 88, 95,

216, 95, 88,223, 88, 95, 88, 88, 88, 95, 88, 88, 95, 88, 95, 88,

95, 88, 88, 95, 88, 88, 88, 95, 88, 88, 95, 88, 95, 88, 88, 95,

88, 95, 88, 88, 88, 88,223, 88, 95, 88, 95, 88,223, 88, 95, 88,

88, 88, 88, 88, 95, 95, 88, 88,223, 95, 88, 88,216, 95,223, 88,

88, 88, 95, 95, 88, 80, 96,224,231, 12, 8,216,224,240,248,254}

};

//WORLD MAP

unsigned char const arr3[8][128] =

{

{

0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0x7F,0x7F,

0x7F,0x7F,0x7F,0x7F,0x7F,0x7F,0xFF,0xFF,

0xFF,0xFF,0x7F,0x7F,0x3F,0xBF,0x3F,0x1F,

0x3F,0x3F,0x3F,0x7F,0xFF,0xBF,0x1F,0x47,

0x87,0x07,0x07,0x07,0x27,0x77,0x77,0x67,

0xE7,0xE7,0xE7,0xC7,0x87,0x07,0x07,0x07,

0x07,0x07,0x07,0x07,0x07,0x07,0x07,0x87,

0xC7,0xF7,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,

Page 55: RTC using ghraphical LCD 2003

0xFF,0xFF,0xFF,0xFF,0xFF,0xEF,0xEF,0x7F,

0x7F,0x7F,0x7F,0xFF,0xFF,0xFF,0xFF,0xFF,

0xFF,0xFF,0xFF,0xBF,0xFF,0xFF,0xFF,0xFF,

0x3F,0x7F,0x7F,0x7F,0x3F,0x3F,0x3F,0x1F,

0x1F,0x1F,0x1F,0x1F,0x0F,0x1F,0x1F,0x1F,

0x3F,0x3F,0x3F,0x3F,0x3F,0x7F,0x7F,0x7F,

0x7F,0x3F,0x3F,0x7F,0x7F,0x7F,0x7F,0x7F,

0x7F,0xFF,0xFF,0xFF,0x7F,0x7F,0xFF,0xFF},

{0xFE,0xFE,0xFE,0xFF,0xFF,0xFF,0xF8,0xF8,

0xF0,0xF0,0xF8,0xF8,0xF8,0xF8,0xF8,0xF8,

0xF0,0xE0,0xC0,0x80,0x00,0x00,0x00,0x00,

0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x0C,

0x0C,0x0E,0x1C,0x3F,0x0F,0x03,0x00,0x04,

0x04,0x87,0xCF,0x9F,0xFF,0xFE,0xFC,0xF8,

0xF8,0xFC,0xFE,0xFE,0xFF,0xFF,0xFF,0xFF,

0xFF,0xFD,0xFF,0xFF,0xFF,0xDF,0xCF,0x1F,

0x3F,0x3F,0x13,0x03,0x01,0x10,0x1C,0x0C,

0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,

0x00,0x80,0x80,0x00,0x00,0x00,0x00,0x00,

0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,

0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,

0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,

0x00,0x90,0xF8,0xF8,0xF8,0xF8,0xF8,0xCC,

0xE0,0xF0,0xF8,0xF8,0xF8,0xFC,0xFC,0xFE},

{0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,

0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,

0xFF,0xFF,0xFF,0xFF,0xF8,0xF0,0xE0,0xE0,

0xC0,0x80,0x00,0x00,0x00,0x80,0xC0,0xC0,

0xE0,0xE0,0xC0,0xE0,0xF0,0xFC,0xFE,0xFE,

Page 56: RTC using ghraphical LCD 2003

0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,

0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,

0xFF,0xFF,0xFF,0x3F,0x1F,0x09,0x01,0x00,

0x04,0x06,0x06,0x06,0x0E,0x1C,0x1E,0x18,

0x1C,0x18,0x19,0x19,0x01,0x03,0x00,0x00,

0x00,0x07,0x46,0x00,0x00,0x80,0x80,0x80,

0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,

0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,

0x00,0x00,0x84,0xFC,0xF8,0xF4,0xFE,0xFE,

0xF7,0xFB,0xFE,0xFF,0xFF,0xFF,0xFF,0xFF,

0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF},

{0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,

0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,

0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,

0xFF,0xFF,0xFF,0xFC,0xFC,0xFC,0xFD,0xF9,

0xF9,0xF3,0xFF,0xFF,0x5F,0x0F,0x0F,0x0F,

0x0F,0x0F,0x1F,0x3F,0x3F,0x3F,0xFF,0xFF,

0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,

0xFF,0xFF,0xF0,0xE0,0xC0,0xC0,0xC0,0xC0,

0xC0,0xC0,0xC0,0x00,0x00,0x00,0x00,0x00,

0x00,0x00,0x00,0x00,0x00,0x03,0x06,0x00,

0x88,0xC8,0xFC,0xFC,0xFE,0xFF,0xFF,0xFF,

0xFF,0xFE,0xF0,0xE0,0xF8,0xFC,0xFE,0xFF,

0xFE,0xFC,0xF8,0x30,0x30,0xE0,0xF6,0x7F,

0x3F,0x3F,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,

0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,

0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF},

{0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,

0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,

0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,

Page 57: RTC using ghraphical LCD 2003

0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,

0xFF,0xFF,0xFF,0xFD,0xF0,0xE0,0xC0,0x00,

0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,

0x01,0x01,0xF1,0xFB,0xFF,0xFF,0xFF,0xFF,

0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,

0xFF,0xFF,0xFF,0xFE,0x98,0x00,0x00,0x00,

0x00,0x00,0x00,0x00,0x80,0xC0,0xFE,0x7F,

0x1F,0xDF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,

0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,

0xFF,0xFF,0xFF,0xFE,0xFC,0xFF,0xFF,0xFE,

0xFE,0x7F,0x7E,0x3F,0x1F,0x1F,0x0F,0x0F,

0x3D,0x39,0x19,0x3B,0x7F,0xFF,0xFF,0xFF,

0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF},

{0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,

0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,

0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,

0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,

0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0x0F,0x00,

0x00,0x80,0xC0,0xE0,0xF0,0xF8,0xFC,0xFE,

0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,

0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,

0xFF,0xFF,0xFF,0xFF,0xFF,0xFC,0xF0,0xF0,

0xF0,0xF0,0xF8,0xFC,0xFF,0xFF,0xFF,0xFF,

0xFE,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,

0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,

0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,

0xFC,0xF0,0xF0,0xF0,0xF8,0xF8,0xF8,0xF0,

0xF0,0xE0,0xC0,0xC0,0xE0,0xF0,0xFF,0xFF,

0xFF,0xFF,0xFF,0xFF,0x7F,0xFF,0xDF,0xFF},

{0x7F,0x7F,0x7F,0x7F,0x7F,0x7F,0x7F,0x7F,

Page 58: RTC using ghraphical LCD 2003

0x7F,0x7F,0x7F,0x7F,0x7F,0x7F,0x7F,0x7F,

0x7F,0x7F,0x7F,0x7F,0x7F,0x7F,0x7F,0x7F,

0x7F,0x7F,0x7F,0x7F,0x7F,0x7F,0x7F,0x7F,

0x7F,0x7F,0x7F,0x7F,0x7F,0x7F,0x78,0x78,

0x7F,0x7F,0x7F,0x7F,0x7F,0x7F,0x7F,0x7F,

0x7F,0x7F,0x7F,0x7F,0x7F,0x7F,0x7F,0x7F,

0x7F,0x7F,0x7F,0x7F,0x7F,0x7F,0x7F,0x7F,

0x7F,0x7F,0x7F,0x7F,0x7F,0x7F,0x7F,0x7F,

0x7F,0x7F,0x7F,0x7F,0x7F,0x7F,0x7F,0x7F,

0x7F,0x7F,0x7F,0x7F,0x7F,0x7F,0x7F,0x7F,

0x7F,0x7F,0x7F,0x7F,0x7F,0x7F,0x7F,0x7F,

0x7F,0x7F,0x7F,0x7F,0x7F,0x7F,0x7F,0x7F,

0x7F,0x7F,0x7F,0x7F,0x7F,0x7F,0x7F,0x7F,

0x7F,0x7F,0x7F,0x7F,0x7F,0x7F,0x7F,0x7F,

0x7F,0x7F,0x7F,0x7F,0x7F,0x7F,0x7F,0x7F},

{

0x0,0x0,0x0,0x0,0x0,0x0,0x00,0x0,

0x0,0x0,0x0,0x0,0x0,0x0,0x00,0x0,

0x0,0x0,0x0,0x0,0x0,0x0,0x00,0x0,

0x0,0x0,0x0,0x0,0x0,0x0,0x00,0x0,

0x0,0x0,0x0,0x0,0x0,0x0,0x00,0x0,

0x0,0x0,0x0,0x0,0x0,0x0,0x00,0x0,

0x0,0x0,0x0,0x0,0x0,0x0,0x00,0x0,

0x0,0x0,0x0,0x0,0x0,0x0,0x00,0x0,

0x0,0x0,0x0,0x0,0x0,0x0,0x00,0x0,

0x0,0x0,0x0,0x0,0x0,0x0,0x00,0x0,

0x0,0x0,0x0,0x0,0x0,0x0,0x00,0x0,

0x0,0x0,0x0,0x0,0x0,0x0,0x00,0x0,

0x0,0x0,0x0,0x0,0x0,0x0,0x00,0x0,

0x0,0x0,0x0,0x0,0x0,0x0,0x00,0x0,

0x0,0x0,0x0,0x0,0x0,0x0,0x00,0x0,

0x0,0x0,0x0,0x0,0x0,0x0,0x00,0x0}

Page 59: RTC using ghraphical LCD 2003

};

/**MAIN FUCNTION**/

void main()

{

unsigned char i,sel=0;

//PORT PINS DIRECTION INDICATION

DDRA = 0xFF;

DDRC = 0XFF;

PORTD=0XFF;

DDRD.2=0;

DDRD.3=0;

DDRD.4=0;

DDRD.5=0;

DDRD.6=0;

DDRB.1=0;

DDRB.2=0;

DDRB.3=0;

DDRB.4=0;

glcd_init(); //GLCD INITIALIZATION FUNCTION

i2c_init(); //I2C INITIALIZATION FUNCTION

clear_display(); //CLEAR THE SCREEN

strcpyf(Time[6],charset[10]); //':'

strcpyf(Time[9],charset[10]);

strcpyf(Time[15],charset[11]); //'/'

strcpyf(Time[18],charset[11]);

Page 60: RTC using ghraphical LCD 2003

rtc_write(0x00,0x00); //RTC WRITE FUNCTION CALLING

while(1)

{

graph3(); // WORLD MAP

if(sw1==0)

{

graph2(); //TAJ PICTURE

delay_ms(5000);

}

else if(sw2==0)

{

graph0(); //DISPLAY COLLEGE NAME

delay_ms(5000);

}

else if(sw3==0)

{

graph1(); //DISPLAY HOUSE

delay_ms(5000);

}

else if(sw4==0)

{

while(1) //DISPLAY ALL IMAGES CONTINOUSLY

{

graph2();

delay_ms(3000);

graph0();

Page 61: RTC using ghraphical LCD 2003

delay_ms(3000);

graph1();

delay_ms(3000);

}

}

//DISPLAY TIME

strcpyf(Time[0],charset[13]);

strcpyf(Time[1],charset[14]);

strcpyf(Time[2],charset[15]);

strcpyf(Time[3],charset[16]);

i = rtc_read(0x02); //hours

strcpyf(Time[4],charset[i >> 4]);

strcpyf(Time[5],charset[i & 0x0F]);

i = rtc_read(0x01); //min

strcpyf(Time[7],charset[i >> 4]);

strcpyf(Time[8],charset[i & 0x0F]);

i = rtc_read(0x00); //sec

strcpyf(Time[10],charset[i >> 4]);

strcpyf(Time[11],charset[i & 0x0F]);

i = rtc_read(0x04); // date

strcpyf(Time[13],charset[i >> 4]);

strcpyf(Time[14],charset[i & 0x0F]);

i = rtc_read(0x05); //month

strcpyf(Time[16],charset[i >> 4]);

strcpyf(Time[17],charset[i & 0x0F]);

i = rtc_read(0x06); //year

strcpyf(Time[19],charset[i >> 4]);

Page 62: RTC using ghraphical LCD 2003

strcpyf(Time[20],charset[i & 0x0F]);

display_lcd();

if(SEL == 0 )

{

strcpyf(Time[0],charset[16]); //'E'

strcpyf(Time[1],charset[17]); //'D'

strcpyf(Time[2],charset[14]); //'I'

strcpyf(Time[3],charset[13]); //'T'

strcpyf(Time[6],charset[10]); //'10'

strcpyf(Time[9],charset[10]);

strcpyf(Time[4],charset[0]); //'0'

strcpyf(Time[5],charset[0]);

strcpyf(Time[7],charset[0]);

strcpyf(Time[8],charset[0]);

strcpyf(Time[10],charset[0]);

strcpyf(Time[11],charset[0]);

display_lcd();

if(sel==0)

edit_hr();

delay_ms(1);

} //filling the array time it includes TIME :and hours:min:sec which read from rtc

delay_ms(100);

}

}

Page 63: RTC using ghraphical LCD 2003

/**EDIT HOURS FUNCTION**/

void edit_hr()

{

unsigned char j=0,temp;

strcpyf(Time[0],charset[18]); //'H'

strcpyf(Time[1],charset[19]); //'O'

strcpyf(Time[2],charset[20]); //'U'

strcpyf(Time[3],charset[21]); //'R'

do

{

if(INC==0)

j++;

if(DEC==0)

j--;

if(j<=9)

{

strcpyf(Time[5],charset[j]);

}

if(j>9 && j<=19)//above 9 and below 20

{

strcpyf(Time[4],charset[1]);

strcpyf(Time[5],charset[j-10]);

}

if(j>19 && j<=24)//above20

{

strcpyf(Time[4],charset[2]);

Page 64: RTC using ghraphical LCD 2003

strcpyf(Time[5],charset[j-20]);

}

if(j>24)

{

j=0;

strcpyf(Time[4],charset[0]);

strcpyf(Time[5],charset[0]);

}

display_lcd();

delay_ms(100);

}while(SEL==1);

if(j!=0)

{

temp=j%10;

j=j/10;

j=j<<4;

temp=temp|j;

rtc_write(0x02,temp);

delay_ms(100);

}

edit_min();

}

/**EDIT MINITE FUNCTION**/

void edit_min()

{

unsigned char j=0,temp;

strcpyf(Time[0],charset[22]); //'M'

strcpyf(Time[1],charset[23]); //'I'

Page 65: RTC using ghraphical LCD 2003

strcpyf(Time[2],charset[24]); //'N'

strcpyf(Time[3],charset[25]);//'S'

do

{

if(INC==0)

j++;

if(DEC==0)

j--;

if(j<=9)

{

strcpyf(Time[8],charset[j]);

}

if(j>9 && j<=19)//above 9 and below 20

{

strcpyf(Time[7],charset[1]);

strcpyf(Time[8],charset[j-10]);

}

if(j>19 && j<=29)//above20

{

strcpyf(Time[7],charset[2]);

strcpyf(Time[8],charset[j-20]);

}

if(j>29 && j<=39)//above20

{

Page 66: RTC using ghraphical LCD 2003

strcpyf(Time[7],charset[3]);

strcpyf(Time[8],charset[j-30]);

}

if(j>29 && j<=39)//above20

{

strcpyf(Time[7],charset[3]);

strcpyf(Time[8],charset[j-30]);

}

if(j>39 && j<=49)//above20

{

strcpyf(Time[7],charset[4]);

strcpyf(Time[8],charset[j-40]);

}

if(j>49 && j<=59)//above20

{

strcpyf(Time[7],charset[5]);

strcpyf(Time[8],charset[j-50]);

}

if(j==60)

{

Page 67: RTC using ghraphical LCD 2003

j=0;

strcpyf(Time[7],charset[6]);

strcpyf(Time[8],charset[0]);

}

display_lcd();

delay_ms(100);

}while(SEL==1);

if(j!=0)

{

temp=j%10;

j=j/10;

j=j<<4;

temp=temp|j;

rtc_write(0x01,temp);

delay_ms(100);

}

edit_date();

}

/**EDIT DATE FUNCTION**/

void edit_date()

{

unsigned char j=0,temp;

strcpyf(Time[0],charset[17]); //'D'

strcpyf(Time[1],charset[17]);

strcpyf(Time[2],charset[17]);

strcpyf(Time[3],charset[17]);

do

{

Page 68: RTC using ghraphical LCD 2003

if(INC==0)

j++;

if(DEC==0)

j--;

if(j<=9)

{

strcpyf(Time[13],charset[0]);

strcpyf(Time[14],charset[j]);

}

if(j>9 && j<=19)//above 9 and below 20

{

strcpyf(Time[13],charset[1]);

strcpyf(Time[14],charset[j-10]);

}

if(j>19 && j<=29)//above20

{

strcpyf(Time[13],charset[2]);

strcpyf(Time[14],charset[j-20]);

}

if(j==30)

{

j=0;

strcpyf(Time[13],charset[3]);

strcpyf(Time[14],charset[0]);

}

display_lcd();

delay_ms(100);

Page 69: RTC using ghraphical LCD 2003

}while(SEL==1);

if(j!=0)

{

temp=j%10;

j=j/10;

j=j<<4;

temp=temp|j;

rtc_write(0x04,temp);

delay_ms(100);

}

edit_month();

}

//EDIT MONTH FUNCTION

void edit_month()

{

unsigned char j=0,temp;

strcpyf(Time[0],charset[15]); //'M'

strcpyf(Time[1],charset[15]);

strcpyf(Time[2],charset[15]);

strcpyf(Time[3],charset[15]);

do

{

if(INC==0)

j++;

if(DEC==0)

j--;

if(j<=9)

{

strcpyf(Time[16],charset[0]);

strcpyf(Time[17],charset[j]);

Page 70: RTC using ghraphical LCD 2003

}

if(j>9 && j<=12)//above 9 and below 20

{

strcpyf(Time[16],charset[1]);

strcpyf(Time[17],charset[j-10]);

}

display_lcd();

delay_ms(100);

if(j>12)

j=0;

}while(SEL==1);

if(j!=0)

{

temp=j%10;

j=j/10;

j=j<<4;

temp=temp|j;

rtc_write(0x05,temp);

delay_ms(100);

}

edit_year();

}

/**EDIT YEAR FUNCTION**/

void edit_year()

{

unsigned char j=0,temp;

strcpyf(Time[0],charset[26]); //'Y'

strcpyf(Time[1],charset[26]);

strcpyf(Time[2],charset[26]);

strcpyf(Time[3],charset[26]);

Page 71: RTC using ghraphical LCD 2003

do

{

if(INC==0)

j++;

if(DEC==0)

j--;

if(j<=9)

{

strcpyf(Time[19],charset[0]);

strcpyf(Time[20],charset[j]);

}

if(j>9 && j<=19)//above 9 and below 20

{

strcpyf(Time[19],charset[1]);

strcpyf(Time[20],charset[j-10]);

}

if(j>19 && j<=29)//above20

{

strcpyf(Time[19],charset[2]);

strcpyf(Time[20],charset[j-20]);

}

if(j==30)

{

j=0;

strcpyf(Time[19],charset[3]);

strcpyf(Time[20],charset[0]);

}

display_lcd();

delay_ms(100);

}while(EXIT==1);

if(j!=0)

{

temp=j%10;

j=j/10;

Page 72: RTC using ghraphical LCD 2003

j=j<<4;

temp=temp|j;

rtc_write(0x06,temp);

delay_ms(100);

}

}

/**DISPLAY LCD FUNCTION**/

void display_lcd()

{

unsigned char i,j,temp;

for(j=0;j<21;j++)

{

writecmd(0xBF);

for(i=0;i<6;i++)

{

temp = (j * 6) + i;

if(temp <= 63)

{

writecmd(0x40 + temp);

CS1 = 1;

CS2 = 0;

}

if(temp > 63)

{

temp -= 64;

writecmd(0x40 + temp);

CS1 = 0;

CS2 = 1;

Page 73: RTC using ghraphical LCD 2003

}

writedata(Time[j][i]);

}

}

}

/**GRAPHICAL LCD INITIALIZATION**/

void glcd_init(void)

{

RST = 0;

delay_ms(10);

RST = 1;

delay_ms(1);

LCD_EN = 0;

CS1 = 0;

CS2 = 0;

IO = 0;

RS = 0;

writecmd(0x3e); // 0x3E turn it Off.

writecmd(0x3f); // 0x3F Display ON.

writecmd(0x40); // display data in horizontal way(0-63)

writecmd(0xb8); // display data in vertical way(0-7)

writecmd(0xc0); // indicates the display data RAM displayed on the top of the screen

}

/**BUSY CHECK FUNCTION**/

void busy_check(void)

{

delay_us(2);

RS = 0;

IO = 0;

}

/**WRITE COMMAND FUNCTION**/

Page 74: RTC using ghraphical LCD 2003

void writecmd(unsigned char G_lcd)

{

busy_check();

RS = 0;

CS1 = 1;

CS2 = 1; // CS1 AND CS2(P1.23 and P1.24) are enabled.

bus = G_lcd;

LCD_EN = 1; // E->SET.

LCD_EN = 0; // E->CLR.

}

/**WRITE DATA FUNCTION**/

void writedata(unsigned char ch)

{

busy_check();

RS = 1;

bus = ch;

LCD_EN = 1;

LCD_EN = 0;

}

/**CLEAR DISPLAY FUNCTION**/

void clear_display()

{

pageclear();

}

/**PAGE CLEAR FUNCTION**/

void pageclear(void)

Page 75: RTC using ghraphical LCD 2003

{

int i,y;

CS1 = 1;

CS2 = 1; // CS1 AND CS2(P1.23 and P1.24) are enabled.

for(i=0xb8;i<0xc0;i++)

{

writecmd(i); // Select Pages.

writecmd(0x40);

for (y=0;y<64;y++)

writedata(0x00); // Clear data in the LCD.

}

}

/**GRAPH0 FUNCTION DECLARATION**/

void graph0()

{

int i,j;

for(j=0;j<8;j++)

{

writecmd(0xB8+j);

writecmd(0x40);

CS1 = 1; // PAGE 1 IS SELECGTED.

CS2 = 0; // PAGE 2 IS DISABLE.

for(i=0;i<128;i++)

{

if(i==64)

{

CS2 = 1; //PAGE 2 IS SELECGTED

CS1 = 0; //PAGE 1 IS DISABLE.

Page 76: RTC using ghraphical LCD 2003

}

writedata(arr0[j][i]);

}

}

}

/**GRAPH1 FUNCTION DECLARATION**/

void graph1()

{

int i,j;

for(j=0;j<8;j++)

{

writecmd(0xB8+j);

writecmd(0x40);

CS1 = 1; // PAGE 1 IS SELECGTED.

CS2 = 0; // PAGE 2 IS DISABLE.

for(i=0;i<128;i++)

{

if(i==64)

{

CS2 = 1; //PAGE 2 IS SELECGTED

CS1 = 0; //PAGE 1 IS DISABLE.

}

writedata(arr1[j][i]);

}

}

}

/**GRAPH2 FUNCTION DECLARATION**/

void graph2()

Page 77: RTC using ghraphical LCD 2003

{

int i,j;

for(j=0;j<8;j++)

{

writecmd(0xB8+j);

writecmd(0x40);

CS1 = 1; // PAGE 1 IS SELECGTED.

CS2 = 0; // PAGE 2 IS DISABLE.

for(i=0;i<128;i++)

{

if(i==64)

{

CS2 = 1; //PAGE 2 IS SELECGTED

CS1 = 0; //PAGE 1 IS DISABLE.

}

writedata(arr2[j][i]);

}

}

}

/**GRAPH3 FUNCTION DECLARATION**/

void graph3()

{

int i,j;

for(j=0;j<8;j++)

{

writecmd(0xB8+j);

writecmd(0x40);

Page 78: RTC using ghraphical LCD 2003

CS1 = 1; // PAGE 1 IS SELECGTED.

CS2 = 0; // PAGE 2 IS DISABLE.

for(i=0;i<128;i++)

{

if(i==64)

{

CS2 = 1; //PAGE 2 IS SELECGTED

CS1 = 0; //PAGE 1 IS DISABLE.

}

writedata(arr3[j][i]);

}

}

}

/**RTC READ FUNCTION**/

unsigned char rtc_read(unsigned char address)

{

unsigned char data;

i2c_start();

i2c_write(RTC_BUS_ADDRESS);

i2c_write(address);

i2c_start();

i2c_write(RTC_BUS_ADDRESS | 1);

data=i2c_read(0);

i2c_stop();

return data;

}

/**WRITE A BYTE TO EEPROM**/

void rtc_write(unsigned char address, unsigned char data)

{

i2c_start();

Page 79: RTC using ghraphical LCD 2003

i2c_write(RTC_BUS_ADDRESS);

i2c_write(address);

i2c_write(data);

i2c_stop();

/* 10ms delay to complete the write operation */

delay_ms(10);

}

REFERCENCE

Page 80: RTC using ghraphical LCD 2003

TEXT BOOKS REFERED:

1. “The 8051 Microcontroller and Embedded Systems” by Muhammad Ali Mazidi and Janice Gillispie

Mazidi, Pearson Education.

2. 8051 Microcontroller Architecture, programming and application by KENNETH JAYALA

3. ATMEL 89s52 Data sheets

4. Hand book for Digital IC’s from Analogic Devices

WEBSITES VIEWED:

www.atmel.com

www.beyondlogic.org

www.dallassemiconductors.com

www.maxim-ic.com

www.alldatasheets.com

www.howstuffworks.com