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

Delays in verilog
Delays in verilogDelays in verilog
Delays in verilogJITU MISTRY
 
Microcontroller-8051.ppt
Microcontroller-8051.pptMicrocontroller-8051.ppt
Microcontroller-8051.pptDr.YNM
 
Architecture of 8051 microcontroller))
Architecture of 8051 microcontroller))Architecture of 8051 microcontroller))
Architecture of 8051 microcontroller))Ganesh Ram
 
Architecture of 8085 microprocessor
Architecture of 8085 microprocessorArchitecture of 8085 microprocessor
Architecture of 8085 microprocessorAMAN SRIVASTAVA
 
8051 Microcontroller PPT's By Er. Swapnil Kaware
8051 Microcontroller PPT's By Er. Swapnil Kaware8051 Microcontroller PPT's By Er. Swapnil Kaware
8051 Microcontroller PPT's By Er. Swapnil KawareProf. Swapnil V. Kaware
 
VHDL-PRESENTATION.ppt
VHDL-PRESENTATION.pptVHDL-PRESENTATION.ppt
VHDL-PRESENTATION.pptDr.YNM
 
Microprocessor Interfacing and 8155 Features
Microprocessor Interfacing and 8155 FeaturesMicroprocessor Interfacing and 8155 Features
Microprocessor Interfacing and 8155 FeaturesSrikrishna Thota
 
8085 microprocessor architecture ppt
8085 microprocessor architecture ppt8085 microprocessor architecture ppt
8085 microprocessor architecture pptParvesh Gautam
 
Microcontroller 8051
Microcontroller 8051Microcontroller 8051
Microcontroller 8051John Williams
 
Rtos concepts
Rtos conceptsRtos concepts
Rtos conceptsanishgoel
 
Memory & I/O interfacing
Memory & I/O  interfacingMemory & I/O  interfacing
Memory & I/O interfacingdeval patel
 

What's hot (20)

ARM Architecture
ARM ArchitectureARM Architecture
ARM Architecture
 
Delays in verilog
Delays in verilogDelays in verilog
Delays in verilog
 
Microcontroller-8051.ppt
Microcontroller-8051.pptMicrocontroller-8051.ppt
Microcontroller-8051.ppt
 
Serial Data Communication
Serial Data CommunicationSerial Data Communication
Serial Data Communication
 
Introduction to Microcontroller
Introduction to MicrocontrollerIntroduction to Microcontroller
Introduction to Microcontroller
 
8051 block diagram
8051 block diagram8051 block diagram
8051 block diagram
 
Architecture of 8051 microcontroller))
Architecture of 8051 microcontroller))Architecture of 8051 microcontroller))
Architecture of 8051 microcontroller))
 
8051 interfacing
8051 interfacing8051 interfacing
8051 interfacing
 
Architecture of 8085 microprocessor
Architecture of 8085 microprocessorArchitecture of 8085 microprocessor
Architecture of 8085 microprocessor
 
Serial Communication in 8051
Serial Communication in 8051Serial Communication in 8051
Serial Communication in 8051
 
VLIW Processors
VLIW ProcessorsVLIW Processors
VLIW Processors
 
8051 Microcontroller PPT's By Er. Swapnil Kaware
8051 Microcontroller PPT's By Er. Swapnil Kaware8051 Microcontroller PPT's By Er. Swapnil Kaware
8051 Microcontroller PPT's By Er. Swapnil Kaware
 
VHDL-PRESENTATION.ppt
VHDL-PRESENTATION.pptVHDL-PRESENTATION.ppt
VHDL-PRESENTATION.ppt
 
Microprocessor Interfacing and 8155 Features
Microprocessor Interfacing and 8155 FeaturesMicroprocessor Interfacing and 8155 Features
Microprocessor Interfacing and 8155 Features
 
8085 microprocessor architecture ppt
8085 microprocessor architecture ppt8085 microprocessor architecture ppt
8085 microprocessor architecture ppt
 
8086 micro processor
8086 micro processor8086 micro processor
8086 micro processor
 
Microcontroller 8051
Microcontroller 8051Microcontroller 8051
Microcontroller 8051
 
Serial data transfer
Serial data transferSerial data transfer
Serial data transfer
 
Rtos concepts
Rtos conceptsRtos concepts
Rtos concepts
 
Memory & I/O interfacing
Memory & I/O  interfacingMemory & I/O  interfacing
Memory & I/O interfacing
 

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
 
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)
 
Loudness and pitch
Loudness and pitchLoudness and pitch
Loudness and pitch
 

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

Work-Permit-Receiver-in-Saudi-Aramco.pptx
Work-Permit-Receiver-in-Saudi-Aramco.pptxWork-Permit-Receiver-in-Saudi-Aramco.pptx
Work-Permit-Receiver-in-Saudi-Aramco.pptxJuliansyahHarahap1
 
Unleashing the Power of the SORA AI lastest leap
Unleashing the Power of the SORA AI lastest leapUnleashing the Power of the SORA AI lastest leap
Unleashing the Power of the SORA AI lastest leapRishantSharmaFr
 
Generative AI or GenAI technology based PPT
Generative AI or GenAI technology based PPTGenerative AI or GenAI technology based PPT
Generative AI or GenAI technology based PPTbhaskargani46
 
Design For Accessibility: Getting it right from the start
Design For Accessibility: Getting it right from the startDesign For Accessibility: Getting it right from the start
Design For Accessibility: Getting it right from the startQuintin Balsdon
 
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
 
CCS335 _ Neural Networks and Deep Learning Laboratory_Lab Complete Record
CCS335 _ Neural Networks and Deep Learning Laboratory_Lab Complete RecordCCS335 _ Neural Networks and Deep Learning Laboratory_Lab Complete Record
CCS335 _ Neural Networks and Deep Learning Laboratory_Lab Complete RecordAsst.prof M.Gokilavani
 
Unit 2- Effective stress & Permeability.pdf
Unit 2- Effective stress & Permeability.pdfUnit 2- Effective stress & Permeability.pdf
Unit 2- Effective stress & Permeability.pdfRagavanV2
 
VIP Call Girls Palanpur 7001035870 Whatsapp Number, 24/07 Booking
VIP Call Girls Palanpur 7001035870 Whatsapp Number, 24/07 BookingVIP Call Girls Palanpur 7001035870 Whatsapp Number, 24/07 Booking
VIP Call Girls Palanpur 7001035870 Whatsapp Number, 24/07 Bookingdharasingh5698
 
Intze Overhead Water Tank Design by Working Stress - IS Method.pdf
Intze Overhead Water Tank  Design by Working Stress - IS Method.pdfIntze Overhead Water Tank  Design by Working Stress - IS Method.pdf
Intze Overhead Water Tank Design by Working Stress - IS Method.pdfSuman Jyoti
 
XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX
XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX
XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXssuser89054b
 
UNIT - IV - Air Compressors and its Performance
UNIT - IV - Air Compressors and its PerformanceUNIT - IV - Air Compressors and its Performance
UNIT - IV - Air Compressors and its Performancesivaprakash250
 
notes on Evolution Of Analytic Scalability.ppt
notes on Evolution Of Analytic Scalability.pptnotes on Evolution Of Analytic Scalability.ppt
notes on Evolution Of Analytic Scalability.pptMsecMca
 
Intro To Electric Vehicles PDF Notes.pdf
Intro To Electric Vehicles PDF Notes.pdfIntro To Electric Vehicles PDF Notes.pdf
Intro To Electric Vehicles PDF Notes.pdfrs7054576148
 
Call Girls Pimpri Chinchwad Call Me 7737669865 Budget Friendly No Advance Boo...
Call Girls Pimpri Chinchwad Call Me 7737669865 Budget Friendly No Advance Boo...Call Girls Pimpri Chinchwad Call Me 7737669865 Budget Friendly No Advance Boo...
Call Girls Pimpri Chinchwad Call Me 7737669865 Budget Friendly No Advance Boo...roncy bisnoi
 

Recently uploaded (20)

Work-Permit-Receiver-in-Saudi-Aramco.pptx
Work-Permit-Receiver-in-Saudi-Aramco.pptxWork-Permit-Receiver-in-Saudi-Aramco.pptx
Work-Permit-Receiver-in-Saudi-Aramco.pptx
 
Call Girls in Netaji Nagar, Delhi 💯 Call Us 🔝9953056974 🔝 Escort Service
Call Girls in Netaji Nagar, Delhi 💯 Call Us 🔝9953056974 🔝 Escort ServiceCall Girls in Netaji Nagar, Delhi 💯 Call Us 🔝9953056974 🔝 Escort Service
Call Girls in Netaji Nagar, Delhi 💯 Call Us 🔝9953056974 🔝 Escort Service
 
(INDIRA) Call Girl Bhosari Call Now 8617697112 Bhosari Escorts 24x7
(INDIRA) Call Girl Bhosari Call Now 8617697112 Bhosari Escorts 24x7(INDIRA) Call Girl Bhosari Call Now 8617697112 Bhosari Escorts 24x7
(INDIRA) Call Girl Bhosari Call Now 8617697112 Bhosari Escorts 24x7
 
Unleashing the Power of the SORA AI lastest leap
Unleashing the Power of the SORA AI lastest leapUnleashing the Power of the SORA AI lastest leap
Unleashing the Power of the SORA AI lastest leap
 
Generative AI or GenAI technology based PPT
Generative AI or GenAI technology based PPTGenerative AI or GenAI technology based PPT
Generative AI or GenAI technology based PPT
 
Design For Accessibility: Getting it right from the start
Design For Accessibility: Getting it right from the startDesign For Accessibility: Getting it right from the start
Design For Accessibility: Getting it right from the start
 
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
 
CCS335 _ Neural Networks and Deep Learning Laboratory_Lab Complete Record
CCS335 _ Neural Networks and Deep Learning Laboratory_Lab Complete RecordCCS335 _ Neural Networks and Deep Learning Laboratory_Lab Complete Record
CCS335 _ Neural Networks and Deep Learning Laboratory_Lab Complete Record
 
Unit 2- Effective stress & Permeability.pdf
Unit 2- Effective stress & Permeability.pdfUnit 2- Effective stress & Permeability.pdf
Unit 2- Effective stress & Permeability.pdf
 
VIP Call Girls Palanpur 7001035870 Whatsapp Number, 24/07 Booking
VIP Call Girls Palanpur 7001035870 Whatsapp Number, 24/07 BookingVIP Call Girls Palanpur 7001035870 Whatsapp Number, 24/07 Booking
VIP Call Girls Palanpur 7001035870 Whatsapp Number, 24/07 Booking
 
Intze Overhead Water Tank Design by Working Stress - IS Method.pdf
Intze Overhead Water Tank  Design by Working Stress - IS Method.pdfIntze Overhead Water Tank  Design by Working Stress - IS Method.pdf
Intze Overhead Water Tank Design by Working Stress - IS Method.pdf
 
XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX
XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX
XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX
 
UNIT - IV - Air Compressors and its Performance
UNIT - IV - Air Compressors and its PerformanceUNIT - IV - Air Compressors and its Performance
UNIT - IV - Air Compressors and its Performance
 
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
 
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
 
(INDIRA) Call Girl Meerut Call Now 8617697112 Meerut Escorts 24x7
(INDIRA) Call Girl Meerut Call Now 8617697112 Meerut Escorts 24x7(INDIRA) Call Girl Meerut Call Now 8617697112 Meerut Escorts 24x7
(INDIRA) Call Girl Meerut Call Now 8617697112 Meerut Escorts 24x7
 
notes on Evolution Of Analytic Scalability.ppt
notes on Evolution Of Analytic Scalability.pptnotes on Evolution Of Analytic Scalability.ppt
notes on Evolution Of Analytic Scalability.ppt
 
Intro To Electric Vehicles PDF Notes.pdf
Intro To Electric Vehicles PDF Notes.pdfIntro To Electric Vehicles PDF Notes.pdf
Intro To Electric Vehicles PDF Notes.pdf
 
Call Now ≽ 9953056974 ≼🔝 Call Girls In New Ashok Nagar ≼🔝 Delhi door step de...
Call Now ≽ 9953056974 ≼🔝 Call Girls In New Ashok Nagar  ≼🔝 Delhi door step de...Call Now ≽ 9953056974 ≼🔝 Call Girls In New Ashok Nagar  ≼🔝 Delhi door step de...
Call Now ≽ 9953056974 ≼🔝 Call Girls In New Ashok Nagar ≼🔝 Delhi door step de...
 
Call Girls Pimpri Chinchwad Call Me 7737669865 Budget Friendly No Advance Boo...
Call Girls Pimpri Chinchwad Call Me 7737669865 Budget Friendly No Advance Boo...Call Girls Pimpri Chinchwad Call Me 7737669865 Budget Friendly No Advance Boo...
Call Girls Pimpri Chinchwad Call Me 7737669865 Budget Friendly No Advance Boo...
 

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