220 likes | 330 Views
NFC-IET-2011. System Programming. Lecture-17 Real Time Clock Dated: May 30, 2011 By Somia Razzaq Note: Some slides and images of following lecture are taken from VU. Time Updation Through INT8. Real Time Clock Device. Battery powered device Updates time even if PC is shutdown
E N D
NFC-IET-2011 System Programming Lecture-17 Real Time Clock Dated: May 30, 2011 By Somia Razzaq Note: Some slides and images of following lecture are taken from VU
Time Updation Through INT8 Real Time Clock Device • Battery powered device • Updates time even if PC is shutdown • RTC has 64 byte battery powered RAM • INT 1AH used to get/set time.
Clock Counter 1AH/00 (hours*60*60 + min*60 + sec) * 18.2065 ON ENTRY AH = 00 ON EXIT AL = Midnight flag CX = Clock count (Hi word) DX = Clock count (Low word) 1573040 Times Increment 1573040/18.2065 = 86399.9121 sec Whereas 86400 sec represent 24 hrs.
AL = 1 if Midnight passedAL = 0 if Midnight not passedSet Clock Counter 1AH/01 ON ENTRY AH = 01 CX = Clock count (Hi word) DX = Clock count (Low word)
Read Time 1AH/02 ON ENTRY AH = 02 ON EXIT CH = Hours (BCD) CL = Minutes (BCD) DH = Seconds (BCD)
Set Time 1AH/03 ON ENTRY AH = 03 CH = Hours (BCD) CL = Minutes (BCD) DH = Seconds (BCD) DL = Day Light saving = 1 Standard Time = 0
Read Date 1AH/04 ON ENTRY AH = 04 ON EXIT CH = Century (BCD) CL = Year (BCD) DH = Month (BCD) DL = Day (BCD)
Set Date 1AH/05 ON ENTRY AH = 05 CH = Century (BCD) CL = Year (BCD) DH = Month (BCD) DL = Day (BCD)
Set Alarm 1AH/06 ON ENTRY AH = 06 CH = Hours (BCD) CL = Minutes (BCD) DH = Seconds (BCD) Interrupt = 04Ah Intercept this interrupt (e.g. On the speakers)
Disable Alarm 1AH/07 ON ENTRY AH = 07
Read Alarm 1AH/09 ON ENTRY AH = 09 ON EXIT CH = Hours (BCD) CL = Minutes (BCD) DH = Seconds (BCD) DL = Alarm Status (00 = Not Enable 01 = Enable)
Real Time Clock Clock and Logic circuitry 64 Bytes Battery Powered Low power CMOS RAM 70H Control Circuitry 71H :::::::::::::::::::::::::::::::::::: INT 7FH
Internal Ports 70 – 7FH (16 ports) Only 70 & 71H are important from programming point of view It can also interrupt microprocessor using IRQ8
64 Byte Battery Powered RAM 00H = Current Second 01H = Alarm Second 02H = Current Minute 03H = Alarm Minute 04H = Current Hour 05H = Alarm Hour 06H = Day Of the Week 07H = Number Of Day
64 Byte Battery Powered RAM 08H = Month 09H = Year 0AH = Clock Status Register A 0BH = Clock Status Register B 0CH = Clock Status Register C 0DH = Clock Status Register D 32H = Century
Week Day 01H = Sunday 02H = Monday 03H = Tuesday 04H = Wednesday 05H = Thursday 06H = Friday 07H = Saturday
Year No of Century and Year are in BCD.
Accessing the Battery Powered RAM Battery Powered RAM is accessed in two steps • Specify the Byte no. in 70H port. • Read/write port 71H to get/set the value of specified byte.
Accessing the Battery Powered RAM outport (0x70, 0); outport (0x70, 4); sec = inport (0x71); outport (0x71,hrs);
Status Register A 7 6 5 4 3 2 1 0 Interrupt frequency Time frequency 0 = Time is not updated 1 = Time is updated
Status Register B 7 6 5 4 3 2 1 0 0 = Daylight saving time Update time 24/12 – hour counter 0 = 12 hour format 1 = 24 hour format Call periodic interrupt Call Alarm interrupt Call interrupt on time update Time & date format 0 = BCD 1 = Binary Block generator
Status Register C 7 6 5 4 3 2 1 0 1 = Time update complete 1 = Alarm time reached 1 = Periodic interrupt call