SlideShare a Scribd company logo
1 of 30
1 
The 8051 Microcontroller and 
Embedded Systems 
CHAPTER 15 
RTC Interfacing and 
Programming
Introduction of Real Time Clock 
 The real-time clock (RTC) is a widely used 
device that provides accurate time and date 
for many applications 
 Many systems such as the x86 IBM PC come 
with such a chip on the motherboard 
 The RTC chip in the IBM PC provides time 
components of hour, minute, and second, in 
addition to the date/calendar components of 
year, month, and day 
2
Introduction of Real Time Clock 
 The RTC chip uses an internal battery, which 
keeps the time and date even when the 
power is off 
 One of the most widely used RTC chips is 
the DS 12887 from Dallas Semiconductor 
/Maxim Corp 
 It uses an internal lithium battery to keep 
operating for over 10 years in the absence of 
external power 
3
Introduction of Real Time Clock 
 According to the DS 12887 data sheet from 
Maxim, it keeps track of “seconds, minutes, 
hours, days, day of week, date, month, and 
year with leap-year compensation valid up to 
year 2100″ 
 The above information is provided in both 
binary (hex) and BCD formats. The DS 
12887 supports both 12-hour and 24-hour 
clock modes with AM and PM in the 12-hour 
4 mode
 It also supports the Daylight Savings Time 
option 
 The DS 12887 uses CMOS technology to 
keep the power consumption low and it has 
the designation DS12C887, where C is for 
CMOS 
 The DS12887 has a total of 128 bytes of 
nonvolatile RAM 
5 
Introduction of Real Time Clock
 It uses 14 bytes of RAM for clock/calendar 
and control registers, and the other 114 
bytes of RAM are for general-purpose data 
storage 
 In the x86 IBM PC, these 114 bytes of NV-RAM 
are used for the CMOS configuration, 
where the system setups are kept before the 
operating system takes over 
6 
Introduction of Real Time Clock
Pin Diagram of DS12887 RTC 
7
Address map of the DS12887 
8
 The DS12887 has a total of 128 bytes of 
RAM space with addresses 00 -7FH 
 The first ten locations, 00 – 09, are set aside 
for RTC values of time, calendar, and alarm 
data 
 The next four bytes are used for the control 
and status registers 
9 
Address map of the DS12887
 They are registers A, B, C, and D and are 
located at addresses 10-13 (OA – OD in hex) 
 The next 114 bytes from addresses OEH to 
7FH are available for data storage 
 The entire 128 bytes of RAM are accessible 
directly for read or write except the following: 
– Registers C and D are read-only 
– D7 bit of register A is read-only 
– The high-order bit of the seconds byte is read-only 
10 
Address map of the DS12887
DS12887 Address Location for 
Time, Calendar, and Alarm 
11
Interfacing of DS12887 with 8051 
12
Turning on the oscillator for the 
first time 
 The DS12887 is equipped with the internal 
oscillator which is turned off in order to save 
the lithium battery. 
 We need to turn on the oscillator before we 
use the time keeping features of the DS 
12887 
 To do that, bits D6 – D4 of register A must be 
set to value 010 
13
Register A Bits for Turning on the 
DS12887′s Oscillator 
14
Code for turning ON DS12887 
 ACALL DELAY_200MS ;Giving settling time 
 MOV R0,#0AH ; Reg A address of DS12887 
 MOV A,#20H ; 010 DATA FOR D6-D4 
 MOVX @R0,A 
15
Bits of Register B 
16
Register C 
17 
– IRQF =1: if PF = PIE= 1 orAF=AIE= 1 orUF = 
UIE= 1 
– PF Periodic interrupt flag. Periodic interrupts can 
be generated at a rate of once every 500 ms to 
once every 122 us. The rate is set by bits RS3 – 
RSO of register A
Register C 
 AF Alarm interrupt flag. The AF becomes 1 
when the current real time matches the alarm 
time. AF and AIE of register B together (if 
both are 1) will allow the IRQ to be 
asserted low when all the three bytes of the 
real time (yy:mm:dd) are the same as the 
bytes in the alarm time 
 The AF also becomes 1 for cases of once 
per second, once per minute, and once per 
18 hour alarm
ALARM AND SQW FEATURES OF 
THE DS12887 CHIP 
19 
The SQW pin 
provides us a 
square wave 
output of various 
frequencies 
The frequency is 
chosen by bits 
RSO – RS3 of 
register A
 Also enable SQWE bit in Register B 
20 
ALARM AND SQW FEATURES OF 
THE DS12887 CHIP
ALARM FEATURE OF DS12887 
CHIP 
 The alarm interrupt can be programmed to 
occur at rates of 
– (a) once per day 
– (b) once per hour 
– (c) once per minute 
– (d) once per second 
21
Once-per-day alarm 
 To program the alarm for once per day, we 
write the desired time for the alarm into the 
hour, minute, and second RAM locations 1, 
3, and 5 
 As the clock keeps the time, when all three 
bytes of hour, minute, and second for the 
real time clock match the values in the alarm 
hour, minute, and second, the AF (alarm 
flag) bit in register C of the DS 12887 will go 
22 high
Once-per-hour, minute and second 
alarms 
 To program the alarm for once per hour, we 
write value FFH into the alarm hour location 
of 5 only 
 To program the alarm for once per minute, 
we write value FFH into both the alarm hour 
and alarm minute locations of 5 and 3 
 To program the alarm for once per second, 
we write value FFH into all three locations of 
alarm hour, alarm minute, and alarm second 
23
 We can poll the AF bit in register C, which is 
a waste of microcontroller resources, or allow 
the IRQ pin to be activated upon matching 
the alarm time with the real time 
 It must be noted that in order to use the IRQ 
pin of the DS 12887 for an alarm, the 
interrupt-enable bit for alarm in register B 
(AIE) must be set high 
24 
IRQ FEATURE OF THE DS12887 
CHIP
IRQ FEATURE OF THE DS12887 
CHIP 
25
 Interrupt request (IRQ) is an output pin for 
the DS12887 RTC chip 
 There are three possible sources that can 
activate the IRQ pin 
– (a) alarm interrupt 
– (b) periodic pulse interrupt 
– (c) update interrupt 
 We can choose which source to activate the 
IRQ pin using the interrupt-enable bit in 
register B of the DS 12887 
26 
IRQ FEATURE OF THE DS12887 
CHIP
PERIODIC INTERRUPT 
 The second source of interrupt is the periodic 
interrupt flag (PF) 
 The periodic interrupt flag is part of register C 
 It will go high at a rate set by the RS3 -RSO 
bits of register A 
 This rate can be from once every 500 ms to 
once every 122 us as shown 
 The PF becomes 1 when an edge is detected 
27 for the period
 Just like alarm interrupt, the periodic interrupt 
can also be directed to the IRQ pin 
 To use IRQ, the interrupt-enable bits of PIE 
in register B must be set to 1 
 In other words, we can poll the PF bit of 
register C, which is a waste of the 
microcontroller’s resources, or it can be 
directed to the hardware IRQ pin 
 If we set PIE = 1, the IRQ pin is asserted low 
when PF goes high 
28 
PERIODIC INTERRUPT
 While the alarm interrupt gave us the options 
from once per day to once per second, the 
periodic interrupt gives us the option of 
subsecond interrupts 
 For example, we can write a program to send 
a message to the screen twice per second (2 
Hz) 
29 
PERIODIC INTERRUPT
Internal 
Architecture 
of DS12887 
30

More Related Content

What's hot

SYBSC IT SEM IV EMBEDDED SYSTEMS UNIT I Core of Embedded Systems
SYBSC IT SEM IV EMBEDDED SYSTEMS UNIT I   Core of Embedded SystemsSYBSC IT SEM IV EMBEDDED SYSTEMS UNIT I   Core of Embedded Systems
SYBSC IT SEM IV EMBEDDED SYSTEMS UNIT I Core of Embedded SystemsArti Parab Academics
 
Serial Peripheral Interface(SPI)
Serial Peripheral Interface(SPI)Serial Peripheral Interface(SPI)
Serial Peripheral Interface(SPI)Dhaval Kaneria
 
Timer counter in arm7(lpc2148)
Timer counter in arm7(lpc2148)Timer counter in arm7(lpc2148)
Timer counter in arm7(lpc2148)Aarav Soni
 
Embedded Systems (18EC62) - ARM - 32-Bit Microcontroller (Module 1)
Embedded Systems (18EC62) - ARM - 32-Bit Microcontroller (Module 1)Embedded Systems (18EC62) - ARM - 32-Bit Microcontroller (Module 1)
Embedded Systems (18EC62) - ARM - 32-Bit Microcontroller (Module 1)Shrishail Bhat
 
Architecture of 8051
Architecture of 8051Architecture of 8051
Architecture of 8051hello_priti
 
Interfacing adc
Interfacing adcInterfacing adc
Interfacing adcPRADEEP
 
8259 Programmable Interrupt Controller
8259 Programmable Interrupt Controller8259 Programmable Interrupt Controller
8259 Programmable Interrupt Controllerabhikalmegh
 
Stacks & subroutines 1
Stacks & subroutines 1Stacks & subroutines 1
Stacks & subroutines 1deval patel
 
Addressing modes of 8086
Addressing modes of 8086Addressing modes of 8086
Addressing modes of 8086Dr. AISHWARYA N
 
3.programmable interrupt controller 8259
3.programmable interrupt controller 82593.programmable interrupt controller 8259
3.programmable interrupt controller 8259MdFazleRabbi18
 
Pic microcontroller architecture
Pic microcontroller architecturePic microcontroller architecture
Pic microcontroller architectureDominicHendry
 
Programmable peripheral interface 8255
Programmable peripheral interface 8255Programmable peripheral interface 8255
Programmable peripheral interface 8255Marajulislam3
 
Lect 3 ARM PROCESSOR ARCHITECTURE
Lect 3  ARM PROCESSOR ARCHITECTURE Lect 3  ARM PROCESSOR ARCHITECTURE
Lect 3 ARM PROCESSOR ARCHITECTURE Dr.YNM
 
I/O port programming in 8051
I/O port programming in 8051I/O port programming in 8051
I/O port programming in 8051ssuser3a47cb
 
Direct memory access (dma) with 8257 DMA Controller
Direct memory access (dma) with 8257 DMA ControllerDirect memory access (dma) with 8257 DMA Controller
Direct memory access (dma) with 8257 DMA ControllerMuhammed Afsal Villan
 

What's hot (20)

SYBSC IT SEM IV EMBEDDED SYSTEMS UNIT I Core of Embedded Systems
SYBSC IT SEM IV EMBEDDED SYSTEMS UNIT I   Core of Embedded SystemsSYBSC IT SEM IV EMBEDDED SYSTEMS UNIT I   Core of Embedded Systems
SYBSC IT SEM IV EMBEDDED SYSTEMS UNIT I Core of Embedded Systems
 
Serial Peripheral Interface(SPI)
Serial Peripheral Interface(SPI)Serial Peripheral Interface(SPI)
Serial Peripheral Interface(SPI)
 
TMS320C5x
TMS320C5xTMS320C5x
TMS320C5x
 
Timer counter in arm7(lpc2148)
Timer counter in arm7(lpc2148)Timer counter in arm7(lpc2148)
Timer counter in arm7(lpc2148)
 
8051 serial communication-UART
8051 serial communication-UART8051 serial communication-UART
8051 serial communication-UART
 
Embedded Systems (18EC62) - ARM - 32-Bit Microcontroller (Module 1)
Embedded Systems (18EC62) - ARM - 32-Bit Microcontroller (Module 1)Embedded Systems (18EC62) - ARM - 32-Bit Microcontroller (Module 1)
Embedded Systems (18EC62) - ARM - 32-Bit Microcontroller (Module 1)
 
Architecture of 8051
Architecture of 8051Architecture of 8051
Architecture of 8051
 
Interfacing adc
Interfacing adcInterfacing adc
Interfacing adc
 
I2C introduction
I2C introductionI2C introduction
I2C introduction
 
8259 Programmable Interrupt Controller
8259 Programmable Interrupt Controller8259 Programmable Interrupt Controller
8259 Programmable Interrupt Controller
 
Stacks & subroutines 1
Stacks & subroutines 1Stacks & subroutines 1
Stacks & subroutines 1
 
Addressing modes of 8086
Addressing modes of 8086Addressing modes of 8086
Addressing modes of 8086
 
3.programmable interrupt controller 8259
3.programmable interrupt controller 82593.programmable interrupt controller 8259
3.programmable interrupt controller 8259
 
Pic microcontroller architecture
Pic microcontroller architecturePic microcontroller architecture
Pic microcontroller architecture
 
Programmable peripheral interface 8255
Programmable peripheral interface 8255Programmable peripheral interface 8255
Programmable peripheral interface 8255
 
Lect 3 ARM PROCESSOR ARCHITECTURE
Lect 3  ARM PROCESSOR ARCHITECTURE Lect 3  ARM PROCESSOR ARCHITECTURE
Lect 3 ARM PROCESSOR ARCHITECTURE
 
I/O port programming in 8051
I/O port programming in 8051I/O port programming in 8051
I/O port programming in 8051
 
Direct memory access (dma) with 8257 DMA Controller
Direct memory access (dma) with 8257 DMA ControllerDirect memory access (dma) with 8257 DMA Controller
Direct memory access (dma) with 8257 DMA Controller
 
8251 USART
8251 USART8251 USART
8251 USART
 
ARM CORTEX M3 PPT
ARM CORTEX M3 PPTARM CORTEX M3 PPT
ARM CORTEX M3 PPT
 

Viewers also liked

Audio devices and applications
Audio devices and applicationsAudio devices and applications
Audio devices and applicationsDevashish Raval
 
Motor Control Relay, Pwm, DC and Stepper Motors
Motor Control Relay, Pwm, DC and Stepper MotorsMotor Control Relay, Pwm, DC and Stepper Motors
Motor Control Relay, Pwm, DC and Stepper MotorsDevashish Raval
 
Introduction to Video Signals
Introduction to Video SignalsIntroduction to Video Signals
Introduction to Video SignalsDevashish Raval
 
Question paper with solution the 8051 microcontroller based embedded systems...
Question paper with solution  the 8051 microcontroller based embedded systems...Question paper with solution  the 8051 microcontroller based embedded systems...
Question paper with solution the 8051 microcontroller based embedded systems...manishpatel_79
 
RTOS based Confidential Area Security System
RTOS based Confidential Area Security SystemRTOS based Confidential Area Security System
RTOS based Confidential Area Security Systemajinky gadewar
 
Solution manual 8051 microcontroller by mazidi
Solution manual 8051 microcontroller by mazidiSolution manual 8051 microcontroller by mazidi
Solution manual 8051 microcontroller by mazidiMuhammad Abdullah
 
Television Signal Transmission & Propagation
Television Signal Transmission & PropagationTelevision Signal Transmission & Propagation
Television Signal Transmission & PropagationDevashish Raval
 
Project report on embedded system using 8051 microcontroller
Project  report on embedded system using 8051 microcontrollerProject  report on embedded system using 8051 microcontroller
Project report on embedded system using 8051 microcontrollerVandna Sambyal
 
8051 Microcontroller Notes
8051 Microcontroller Notes8051 Microcontroller Notes
8051 Microcontroller NotesDr.YNM
 
PIC32MX Microcontroller Family
PIC32MX Microcontroller FamilyPIC32MX Microcontroller Family
PIC32MX Microcontroller FamilyPremier Farnell
 
1 introducing embedded systems and the microcontrollers
1 introducing embedded systems and the microcontrollers1 introducing embedded systems and the microcontrollers
1 introducing embedded systems and the microcontrollersBidhu Deka
 
Timer based automatic power cutoff for industrial sealing or packaging machines
Timer based automatic power cutoff for industrial sealing or packaging machinesTimer based automatic power cutoff for industrial sealing or packaging machines
Timer based automatic power cutoff for industrial sealing or packaging machinesEcwayt
 
Intro to micro controller (Atmega16)
Intro to micro controller (Atmega16)Intro to micro controller (Atmega16)
Intro to micro controller (Atmega16)Ramadan Ramadan
 

Viewers also liked (20)

Audio devices and applications
Audio devices and applicationsAudio devices and applications
Audio devices and applications
 
Motor Control Relay, Pwm, DC and Stepper Motors
Motor Control Relay, Pwm, DC and Stepper MotorsMotor Control Relay, Pwm, DC and Stepper Motors
Motor Control Relay, Pwm, DC and Stepper Motors
 
Introduction to Video Signals
Introduction to Video SignalsIntroduction to Video Signals
Introduction to Video Signals
 
Television Receiver
Television ReceiverTelevision Receiver
Television Receiver
 
Question paper with solution the 8051 microcontroller based embedded systems...
Question paper with solution  the 8051 microcontroller based embedded systems...Question paper with solution  the 8051 microcontroller based embedded systems...
Question paper with solution the 8051 microcontroller based embedded systems...
 
RTOS based Confidential Area Security System
RTOS based Confidential Area Security SystemRTOS based Confidential Area Security System
RTOS based Confidential Area Security System
 
8051 microcontrollers
8051 microcontrollers8051 microcontrollers
8051 microcontrollers
 
Sound amplification
Sound amplificationSound amplification
Sound amplification
 
Solution manual 8051 microcontroller by mazidi
Solution manual 8051 microcontroller by mazidiSolution manual 8051 microcontroller by mazidi
Solution manual 8051 microcontroller by mazidi
 
Television Signal Transmission & Propagation
Television Signal Transmission & PropagationTelevision Signal Transmission & Propagation
Television Signal Transmission & Propagation
 
Television Basics
Television BasicsTelevision Basics
Television Basics
 
Digital audio
Digital audioDigital audio
Digital audio
 
Project report on embedded system using 8051 microcontroller
Project  report on embedded system using 8051 microcontrollerProject  report on embedded system using 8051 microcontroller
Project report on embedded system using 8051 microcontroller
 
Interfacing LCD with 8051 Microcontroller
Interfacing LCD with 8051 MicrocontrollerInterfacing LCD with 8051 Microcontroller
Interfacing LCD with 8051 Microcontroller
 
8051 Microcontroller Notes
8051 Microcontroller Notes8051 Microcontroller Notes
8051 Microcontroller Notes
 
Sound fundamentals
Sound fundamentalsSound fundamentals
Sound fundamentals
 
PIC32MX Microcontroller Family
PIC32MX Microcontroller FamilyPIC32MX Microcontroller Family
PIC32MX Microcontroller Family
 
1 introducing embedded systems and the microcontrollers
1 introducing embedded systems and the microcontrollers1 introducing embedded systems and the microcontrollers
1 introducing embedded systems and the microcontrollers
 
Timer based automatic power cutoff for industrial sealing or packaging machines
Timer based automatic power cutoff for industrial sealing or packaging machinesTimer based automatic power cutoff for industrial sealing or packaging machines
Timer based automatic power cutoff for industrial sealing or packaging machines
 
Intro to micro controller (Atmega16)
Intro to micro controller (Atmega16)Intro to micro controller (Atmega16)
Intro to micro controller (Atmega16)
 

Similar to RTC Interfacing and Programming

rtcinterfacingandprogramming-141016105525-conversion-gate01.pptx
rtcinterfacingandprogramming-141016105525-conversion-gate01.pptxrtcinterfacingandprogramming-141016105525-conversion-gate01.pptx
rtcinterfacingandprogramming-141016105525-conversion-gate01.pptxSnehalPawar406569
 
project report on embedded system
project report on embedded systemproject report on embedded system
project report on embedded systemram avtar
 
Advanced Embedded Automatic Car Parking System
	Advanced Embedded Automatic Car Parking System	Advanced Embedded Automatic Car Parking System
Advanced Embedded Automatic Car Parking Systemtheijes
 
microcontroller 8051 17.07.2023.pdf
microcontroller 8051 17.07.2023.pdfmicrocontroller 8051 17.07.2023.pdf
microcontroller 8051 17.07.2023.pdf818Farida
 
Training Report on embedded Systems and Robotics
Training Report on embedded  Systems and RoboticsTraining Report on embedded  Systems and Robotics
Training Report on embedded Systems and RoboticsNIT Raipur
 
Interfacing Of PIC 18F252 Microcontroller with Real Time Clock via I2C Protocol
Interfacing Of PIC 18F252 Microcontroller with Real Time Clock via I2C ProtocolInterfacing Of PIC 18F252 Microcontroller with Real Time Clock via I2C Protocol
Interfacing Of PIC 18F252 Microcontroller with Real Time Clock via I2C ProtocolIJERA Editor
 
Microprocessor and microcontroller
Microprocessor and microcontrollerMicroprocessor and microcontroller
Microprocessor and microcontrollerRavinder Singla
 
Chp4 introduction to the pic microcontroller copy
Chp4 introduction to the pic microcontroller   copyChp4 introduction to the pic microcontroller   copy
Chp4 introduction to the pic microcontroller copymkazree
 
Microprocessor 8085 Chapter 4
Microprocessor 8085 Chapter 4Microprocessor 8085 Chapter 4
Microprocessor 8085 Chapter 4Rishikesh Bhavsar
 
Presentation On: "Micro-controller 8051 & Embedded System"
Presentation On: "Micro-controller 8051 & Embedded System"Presentation On: "Micro-controller 8051 & Embedded System"
Presentation On: "Micro-controller 8051 & Embedded System"surabhii007
 
Introduction to microprocessor
Introduction to microprocessorIntroduction to microprocessor
Introduction to microprocessorRamaPrabha24
 
Industrial training report of embedded system and robotics
Industrial training report of embedded system and roboticsIndustrial training report of embedded system and robotics
Industrial training report of embedded system and roboticsPallavi Bharti
 

Similar to RTC Interfacing and Programming (20)

rtcinterfacingandprogramming-141016105525-conversion-gate01.pptx
rtcinterfacingandprogramming-141016105525-conversion-gate01.pptxrtcinterfacingandprogramming-141016105525-conversion-gate01.pptx
rtcinterfacingandprogramming-141016105525-conversion-gate01.pptx
 
020419.pdf
020419.pdf020419.pdf
020419.pdf
 
digital clock atmega16
digital clock atmega16digital clock atmega16
digital clock atmega16
 
project report on embedded system
project report on embedded systemproject report on embedded system
project report on embedded system
 
Advanced Embedded Automatic Car Parking System
	Advanced Embedded Automatic Car Parking System	Advanced Embedded Automatic Car Parking System
Advanced Embedded Automatic Car Parking System
 
microcontroller 8051 17.07.2023.pdf
microcontroller 8051 17.07.2023.pdfmicrocontroller 8051 17.07.2023.pdf
microcontroller 8051 17.07.2023.pdf
 
Training Report on embedded Systems and Robotics
Training Report on embedded  Systems and RoboticsTraining Report on embedded  Systems and Robotics
Training Report on embedded Systems and Robotics
 
Interfacing Of PIC 18F252 Microcontroller with Real Time Clock via I2C Protocol
Interfacing Of PIC 18F252 Microcontroller with Real Time Clock via I2C ProtocolInterfacing Of PIC 18F252 Microcontroller with Real Time Clock via I2C Protocol
Interfacing Of PIC 18F252 Microcontroller with Real Time Clock via I2C Protocol
 
6.pptx
6.pptx6.pptx
6.pptx
 
Microprocessor and microcontroller
Microprocessor and microcontrollerMicroprocessor and microcontroller
Microprocessor and microcontroller
 
Qb microprocessors
Qb microprocessorsQb microprocessors
Qb microprocessors
 
8051 Presentation
8051 Presentation8051 Presentation
8051 Presentation
 
Chp4 introduction to the pic microcontroller copy
Chp4 introduction to the pic microcontroller   copyChp4 introduction to the pic microcontroller   copy
Chp4 introduction to the pic microcontroller copy
 
Microprocessor 8085 Chapter 4
Microprocessor 8085 Chapter 4Microprocessor 8085 Chapter 4
Microprocessor 8085 Chapter 4
 
Presentation On: "Micro-controller 8051 & Embedded System"
Presentation On: "Micro-controller 8051 & Embedded System"Presentation On: "Micro-controller 8051 & Embedded System"
Presentation On: "Micro-controller 8051 & Embedded System"
 
Pic full note
Pic full notePic full note
Pic full note
 
8085_LAB_PROGRAMS.pdf
8085_LAB_PROGRAMS.pdf8085_LAB_PROGRAMS.pdf
8085_LAB_PROGRAMS.pdf
 
Introduction to microprocessor
Introduction to microprocessorIntroduction to microprocessor
Introduction to microprocessor
 
assignment 1-MC.pdf
assignment 1-MC.pdfassignment 1-MC.pdf
assignment 1-MC.pdf
 
Industrial training report of embedded system and robotics
Industrial training report of embedded system and roboticsIndustrial training report of embedded system and robotics
Industrial training report of embedded system and robotics
 

Recently uploaded

Navigating Complexity: The Role of Trusted Partners and VIAS3D in Dassault Sy...
Navigating Complexity: The Role of Trusted Partners and VIAS3D in Dassault Sy...Navigating Complexity: The Role of Trusted Partners and VIAS3D in Dassault Sy...
Navigating Complexity: The Role of Trusted Partners and VIAS3D in Dassault Sy...Arindam Chakraborty, Ph.D., P.E. (CA, TX)
 
Double Revolving field theory-how the rotor develops torque
Double Revolving field theory-how the rotor develops torqueDouble Revolving field theory-how the rotor develops torque
Double Revolving field theory-how the rotor develops torqueBhangaleSonal
 
data_management_and _data_science_cheat_sheet.pdf
data_management_and _data_science_cheat_sheet.pdfdata_management_and _data_science_cheat_sheet.pdf
data_management_and _data_science_cheat_sheet.pdfJiananWang21
 
PE 459 LECTURE 2- natural gas basic concepts and properties
PE 459 LECTURE 2- natural gas basic concepts and propertiesPE 459 LECTURE 2- natural gas basic concepts and properties
PE 459 LECTURE 2- natural gas basic concepts and propertiessarkmank1
 
Kuwait City MTP kit ((+919101817206)) Buy Abortion Pills Kuwait
Kuwait City MTP kit ((+919101817206)) Buy Abortion Pills KuwaitKuwait City MTP kit ((+919101817206)) Buy Abortion Pills Kuwait
Kuwait City MTP kit ((+919101817206)) Buy Abortion Pills Kuwaitjaanualu31
 
GEAR TRAIN- BASIC CONCEPTS AND WORKING PRINCIPLE
GEAR TRAIN- BASIC CONCEPTS AND WORKING PRINCIPLEGEAR TRAIN- BASIC CONCEPTS AND WORKING PRINCIPLE
GEAR TRAIN- BASIC CONCEPTS AND WORKING PRINCIPLEselvakumar948
 
Hospital management system project report.pdf
Hospital management system project report.pdfHospital management system project report.pdf
Hospital management system project report.pdfKamal Acharya
 
Unit 4_Part 1 CSE2001 Exception Handling and Function Template and Class Temp...
Unit 4_Part 1 CSE2001 Exception Handling and Function Template and Class Temp...Unit 4_Part 1 CSE2001 Exception Handling and Function Template and Class Temp...
Unit 4_Part 1 CSE2001 Exception Handling and Function Template and Class Temp...drmkjayanthikannan
 
A CASE STUDY ON CERAMIC INDUSTRY OF BANGLADESH.pptx
A CASE STUDY ON CERAMIC INDUSTRY OF BANGLADESH.pptxA CASE STUDY ON CERAMIC INDUSTRY OF BANGLADESH.pptx
A CASE STUDY ON CERAMIC INDUSTRY OF BANGLADESH.pptxmaisarahman1
 
Thermal Engineering Unit - I & II . ppt
Thermal Engineering  Unit - I & II . pptThermal Engineering  Unit - I & II . ppt
Thermal Engineering Unit - I & II . pptDineshKumar4165
 
Verification of thevenin's theorem for BEEE Lab (1).pptx
Verification of thevenin's theorem for BEEE Lab (1).pptxVerification of thevenin's theorem for BEEE Lab (1).pptx
Verification of thevenin's theorem for BEEE Lab (1).pptxchumtiyababu
 
Standard vs Custom Battery Packs - Decoding the Power Play
Standard vs Custom Battery Packs - Decoding the Power PlayStandard vs Custom Battery Packs - Decoding the Power Play
Standard vs Custom Battery Packs - Decoding the Power PlayEpec Engineered Technologies
 
DeepFakes presentation : brief idea of DeepFakes
DeepFakes presentation : brief idea of DeepFakesDeepFakes presentation : brief idea of DeepFakes
DeepFakes presentation : brief idea of DeepFakesMayuraD1
 
Tamil Call Girls Bhayandar WhatsApp +91-9930687706, Best Service
Tamil Call Girls Bhayandar WhatsApp +91-9930687706, Best ServiceTamil Call Girls Bhayandar WhatsApp +91-9930687706, Best Service
Tamil Call Girls Bhayandar WhatsApp +91-9930687706, Best Servicemeghakumariji156
 
A Study of Urban Area Plan for Pabna Municipality
A Study of Urban Area Plan for Pabna MunicipalityA Study of Urban Area Plan for Pabna Municipality
A Study of Urban Area Plan for Pabna MunicipalityMorshed Ahmed Rahath
 
School management system project Report.pdf
School management system project Report.pdfSchool management system project Report.pdf
School management system project Report.pdfKamal Acharya
 
Bhubaneswar🌹Call Girls Bhubaneswar ❤Komal 9777949614 💟 Full Trusted CALL GIRL...
Bhubaneswar🌹Call Girls Bhubaneswar ❤Komal 9777949614 💟 Full Trusted CALL GIRL...Bhubaneswar🌹Call Girls Bhubaneswar ❤Komal 9777949614 💟 Full Trusted CALL GIRL...
Bhubaneswar🌹Call Girls Bhubaneswar ❤Komal 9777949614 💟 Full Trusted CALL GIRL...Call Girls Mumbai
 

Recently uploaded (20)

Navigating Complexity: The Role of Trusted Partners and VIAS3D in Dassault Sy...
Navigating Complexity: The Role of Trusted Partners and VIAS3D in Dassault Sy...Navigating Complexity: The Role of Trusted Partners and VIAS3D in Dassault Sy...
Navigating Complexity: The Role of Trusted Partners and VIAS3D in Dassault Sy...
 
Double Revolving field theory-how the rotor develops torque
Double Revolving field theory-how the rotor develops torqueDouble Revolving field theory-how the rotor develops torque
Double Revolving field theory-how the rotor develops torque
 
data_management_and _data_science_cheat_sheet.pdf
data_management_and _data_science_cheat_sheet.pdfdata_management_and _data_science_cheat_sheet.pdf
data_management_and _data_science_cheat_sheet.pdf
 
Call Girls in South Ex (delhi) call me [🔝9953056974🔝] escort service 24X7
Call Girls in South Ex (delhi) call me [🔝9953056974🔝] escort service 24X7Call Girls in South Ex (delhi) call me [🔝9953056974🔝] escort service 24X7
Call Girls in South Ex (delhi) call me [🔝9953056974🔝] escort service 24X7
 
PE 459 LECTURE 2- natural gas basic concepts and properties
PE 459 LECTURE 2- natural gas basic concepts and propertiesPE 459 LECTURE 2- natural gas basic concepts and properties
PE 459 LECTURE 2- natural gas basic concepts and properties
 
Kuwait City MTP kit ((+919101817206)) Buy Abortion Pills Kuwait
Kuwait City MTP kit ((+919101817206)) Buy Abortion Pills KuwaitKuwait City MTP kit ((+919101817206)) Buy Abortion Pills Kuwait
Kuwait City MTP kit ((+919101817206)) Buy Abortion Pills Kuwait
 
GEAR TRAIN- BASIC CONCEPTS AND WORKING PRINCIPLE
GEAR TRAIN- BASIC CONCEPTS AND WORKING PRINCIPLEGEAR TRAIN- BASIC CONCEPTS AND WORKING PRINCIPLE
GEAR TRAIN- BASIC CONCEPTS AND WORKING PRINCIPLE
 
Hospital management system project report.pdf
Hospital management system project report.pdfHospital management system project report.pdf
Hospital management system project report.pdf
 
Unit 4_Part 1 CSE2001 Exception Handling and Function Template and Class Temp...
Unit 4_Part 1 CSE2001 Exception Handling and Function Template and Class Temp...Unit 4_Part 1 CSE2001 Exception Handling and Function Template and Class Temp...
Unit 4_Part 1 CSE2001 Exception Handling and Function Template and Class Temp...
 
Cara Menggugurkan Sperma Yang Masuk Rahim Biyar Tidak Hamil
Cara Menggugurkan Sperma Yang Masuk Rahim Biyar Tidak HamilCara Menggugurkan Sperma Yang Masuk Rahim Biyar Tidak Hamil
Cara Menggugurkan Sperma Yang Masuk Rahim Biyar Tidak Hamil
 
A CASE STUDY ON CERAMIC INDUSTRY OF BANGLADESH.pptx
A CASE STUDY ON CERAMIC INDUSTRY OF BANGLADESH.pptxA CASE STUDY ON CERAMIC INDUSTRY OF BANGLADESH.pptx
A CASE STUDY ON CERAMIC INDUSTRY OF BANGLADESH.pptx
 
Thermal Engineering Unit - I & II . ppt
Thermal Engineering  Unit - I & II . pptThermal Engineering  Unit - I & II . ppt
Thermal Engineering Unit - I & II . ppt
 
Verification of thevenin's theorem for BEEE Lab (1).pptx
Verification of thevenin's theorem for BEEE Lab (1).pptxVerification of thevenin's theorem for BEEE Lab (1).pptx
Verification of thevenin's theorem for BEEE Lab (1).pptx
 
FEA Based Level 3 Assessment of Deformed Tanks with Fluid Induced Loads
FEA Based Level 3 Assessment of Deformed Tanks with Fluid Induced LoadsFEA Based Level 3 Assessment of Deformed Tanks with Fluid Induced Loads
FEA Based Level 3 Assessment of Deformed Tanks with Fluid Induced Loads
 
Standard vs Custom Battery Packs - Decoding the Power Play
Standard vs Custom Battery Packs - Decoding the Power PlayStandard vs Custom Battery Packs - Decoding the Power Play
Standard vs Custom Battery Packs - Decoding the Power Play
 
DeepFakes presentation : brief idea of DeepFakes
DeepFakes presentation : brief idea of DeepFakesDeepFakes presentation : brief idea of DeepFakes
DeepFakes presentation : brief idea of DeepFakes
 
Tamil Call Girls Bhayandar WhatsApp +91-9930687706, Best Service
Tamil Call Girls Bhayandar WhatsApp +91-9930687706, Best ServiceTamil Call Girls Bhayandar WhatsApp +91-9930687706, Best Service
Tamil Call Girls Bhayandar WhatsApp +91-9930687706, Best Service
 
A Study of Urban Area Plan for Pabna Municipality
A Study of Urban Area Plan for Pabna MunicipalityA Study of Urban Area Plan for Pabna Municipality
A Study of Urban Area Plan for Pabna Municipality
 
School management system project Report.pdf
School management system project Report.pdfSchool management system project Report.pdf
School management system project Report.pdf
 
Bhubaneswar🌹Call Girls Bhubaneswar ❤Komal 9777949614 💟 Full Trusted CALL GIRL...
Bhubaneswar🌹Call Girls Bhubaneswar ❤Komal 9777949614 💟 Full Trusted CALL GIRL...Bhubaneswar🌹Call Girls Bhubaneswar ❤Komal 9777949614 💟 Full Trusted CALL GIRL...
Bhubaneswar🌹Call Girls Bhubaneswar ❤Komal 9777949614 💟 Full Trusted CALL GIRL...
 

RTC Interfacing and Programming

  • 1. 1 The 8051 Microcontroller and Embedded Systems CHAPTER 15 RTC Interfacing and Programming
  • 2. Introduction of Real Time Clock  The real-time clock (RTC) is a widely used device that provides accurate time and date for many applications  Many systems such as the x86 IBM PC come with such a chip on the motherboard  The RTC chip in the IBM PC provides time components of hour, minute, and second, in addition to the date/calendar components of year, month, and day 2
  • 3. Introduction of Real Time Clock  The RTC chip uses an internal battery, which keeps the time and date even when the power is off  One of the most widely used RTC chips is the DS 12887 from Dallas Semiconductor /Maxim Corp  It uses an internal lithium battery to keep operating for over 10 years in the absence of external power 3
  • 4. Introduction of Real Time Clock  According to the DS 12887 data sheet from Maxim, it keeps track of “seconds, minutes, hours, days, day of week, date, month, and year with leap-year compensation valid up to year 2100″  The above information is provided in both binary (hex) and BCD formats. The DS 12887 supports both 12-hour and 24-hour clock modes with AM and PM in the 12-hour 4 mode
  • 5.  It also supports the Daylight Savings Time option  The DS 12887 uses CMOS technology to keep the power consumption low and it has the designation DS12C887, where C is for CMOS  The DS12887 has a total of 128 bytes of nonvolatile RAM 5 Introduction of Real Time Clock
  • 6.  It uses 14 bytes of RAM for clock/calendar and control registers, and the other 114 bytes of RAM are for general-purpose data storage  In the x86 IBM PC, these 114 bytes of NV-RAM are used for the CMOS configuration, where the system setups are kept before the operating system takes over 6 Introduction of Real Time Clock
  • 7. Pin Diagram of DS12887 RTC 7
  • 8. Address map of the DS12887 8
  • 9.  The DS12887 has a total of 128 bytes of RAM space with addresses 00 -7FH  The first ten locations, 00 – 09, are set aside for RTC values of time, calendar, and alarm data  The next four bytes are used for the control and status registers 9 Address map of the DS12887
  • 10.  They are registers A, B, C, and D and are located at addresses 10-13 (OA – OD in hex)  The next 114 bytes from addresses OEH to 7FH are available for data storage  The entire 128 bytes of RAM are accessible directly for read or write except the following: – Registers C and D are read-only – D7 bit of register A is read-only – The high-order bit of the seconds byte is read-only 10 Address map of the DS12887
  • 11. DS12887 Address Location for Time, Calendar, and Alarm 11
  • 12. Interfacing of DS12887 with 8051 12
  • 13. Turning on the oscillator for the first time  The DS12887 is equipped with the internal oscillator which is turned off in order to save the lithium battery.  We need to turn on the oscillator before we use the time keeping features of the DS 12887  To do that, bits D6 – D4 of register A must be set to value 010 13
  • 14. Register A Bits for Turning on the DS12887′s Oscillator 14
  • 15. Code for turning ON DS12887  ACALL DELAY_200MS ;Giving settling time  MOV R0,#0AH ; Reg A address of DS12887  MOV A,#20H ; 010 DATA FOR D6-D4  MOVX @R0,A 15
  • 17. Register C 17 – IRQF =1: if PF = PIE= 1 orAF=AIE= 1 orUF = UIE= 1 – PF Periodic interrupt flag. Periodic interrupts can be generated at a rate of once every 500 ms to once every 122 us. The rate is set by bits RS3 – RSO of register A
  • 18. Register C  AF Alarm interrupt flag. The AF becomes 1 when the current real time matches the alarm time. AF and AIE of register B together (if both are 1) will allow the IRQ to be asserted low when all the three bytes of the real time (yy:mm:dd) are the same as the bytes in the alarm time  The AF also becomes 1 for cases of once per second, once per minute, and once per 18 hour alarm
  • 19. ALARM AND SQW FEATURES OF THE DS12887 CHIP 19 The SQW pin provides us a square wave output of various frequencies The frequency is chosen by bits RSO – RS3 of register A
  • 20.  Also enable SQWE bit in Register B 20 ALARM AND SQW FEATURES OF THE DS12887 CHIP
  • 21. ALARM FEATURE OF DS12887 CHIP  The alarm interrupt can be programmed to occur at rates of – (a) once per day – (b) once per hour – (c) once per minute – (d) once per second 21
  • 22. Once-per-day alarm  To program the alarm for once per day, we write the desired time for the alarm into the hour, minute, and second RAM locations 1, 3, and 5  As the clock keeps the time, when all three bytes of hour, minute, and second for the real time clock match the values in the alarm hour, minute, and second, the AF (alarm flag) bit in register C of the DS 12887 will go 22 high
  • 23. Once-per-hour, minute and second alarms  To program the alarm for once per hour, we write value FFH into the alarm hour location of 5 only  To program the alarm for once per minute, we write value FFH into both the alarm hour and alarm minute locations of 5 and 3  To program the alarm for once per second, we write value FFH into all three locations of alarm hour, alarm minute, and alarm second 23
  • 24.  We can poll the AF bit in register C, which is a waste of microcontroller resources, or allow the IRQ pin to be activated upon matching the alarm time with the real time  It must be noted that in order to use the IRQ pin of the DS 12887 for an alarm, the interrupt-enable bit for alarm in register B (AIE) must be set high 24 IRQ FEATURE OF THE DS12887 CHIP
  • 25. IRQ FEATURE OF THE DS12887 CHIP 25
  • 26.  Interrupt request (IRQ) is an output pin for the DS12887 RTC chip  There are three possible sources that can activate the IRQ pin – (a) alarm interrupt – (b) periodic pulse interrupt – (c) update interrupt  We can choose which source to activate the IRQ pin using the interrupt-enable bit in register B of the DS 12887 26 IRQ FEATURE OF THE DS12887 CHIP
  • 27. PERIODIC INTERRUPT  The second source of interrupt is the periodic interrupt flag (PF)  The periodic interrupt flag is part of register C  It will go high at a rate set by the RS3 -RSO bits of register A  This rate can be from once every 500 ms to once every 122 us as shown  The PF becomes 1 when an edge is detected 27 for the period
  • 28.  Just like alarm interrupt, the periodic interrupt can also be directed to the IRQ pin  To use IRQ, the interrupt-enable bits of PIE in register B must be set to 1  In other words, we can poll the PF bit of register C, which is a waste of the microcontroller’s resources, or it can be directed to the hardware IRQ pin  If we set PIE = 1, the IRQ pin is asserted low when PF goes high 28 PERIODIC INTERRUPT
  • 29.  While the alarm interrupt gave us the options from once per day to once per second, the periodic interrupt gives us the option of subsecond interrupts  For example, we can write a program to send a message to the screen twice per second (2 Hz) 29 PERIODIC INTERRUPT