Download presentation
Presentation is loading. Please wait.
1
Lecture 17
2
#include <dos. h> #include <bios
#include <dos.h> #include <bios.h> char ch1,ch2; void initialize (unsigned int com) { outportb ( com+3, inport (com+3) | 0x80); outportb ( com,0x80); outportb( com +1, 0x01); outportb ( com+3, 0x1b); }
3
void main ( ) {. initialize(0x3f8);. while (1). {
void main ( ) { initialize(0x3f8); while (1) { if ( ((inport(0x3fd)&0x20)==0x20) && (kbhit())) { ch1=getche(); outport(0x3f8,ch1); } if (( (inport(0x3fd)&0x01)==1)) { ch2= inport(0x3f8); putch(ch2); } if (( ch1==27) || (ch2==27)) break; } }
4
NULL Modem (Revisited)
CD 1 RxD 2 TxD 3 DTR 4 GND 5 DSR 6 RTS 7 CTS 8 RI 9 CD 1 RxD 2 TxD 3 DTR 4 GND 5 DSR 6 RTS 7 CTS 8 RI 9
5
NULL Modem (Revisited)
CD 1 RxD 2 TxD 3 DTR 4 GND 5 DSR 6 RTS 7 CTS 8 RI 9 CD 1 RxD 2 TxD 3 DTR 4 GND 5 DSR 6 RTS 7 CTS 8 RI 9
6
Software Oriented Flow Control Makes use of Two Control characters.
XON (^S) XOFF (^T)
7
while (1) {. receivedchar = readchar (com);. if (receivedchar == XON)
while (1) { receivedchar = readchar (com); if (receivedchar == XON) { ReadStatus = TRUE; continue; } if (receivedchar == XOFF) { ReadStatus = FALSE; continue; } if (ReadStatus == TRUE) Buf [i++] = receivedchar; }
8
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.
9
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) Times Increment / = sec Whereas sec represent 24 hrs.
10
AL = 1 if Midnight passed AL = 0 if Midnight not passed Set Clock Counter 1AH/01
ON ENTRY AH = 01 CX = Clock count (Hi word) DX = Clock count (Low word)
11
Read Time 1AH/02 ON ENTRY AH = 02 ON EXIT CH = Hours (BCD)
CL = Minutes (BCD) DH = Seconds (BCD)
12
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
13
Read Date 1AH/04 ON ENTRY AH = 04 ON EXIT CH = Century (BCD)
CL = Year (BCD) DH = Month (BCD) DL = Day (BCD)
14
Set Date 1AH/05 ON ENTRY AH = 05 CH = Century (BCD) CL = Year (BCD)
DH = Month (BCD) DL = Day (BCD)
15
Set Alarm 1AH/06 ON ENTRY AH = 06 CH = Hours (BCD) CL = Minutes (BCD)
DH = Seconds (BCD)
16
Disable Alarm 1AH/07 ON ENTRY AH = 07
17
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)
18
Real Time Clock Control Circuitry
Clock and Logic circuitry 64 Bytes Battery Powered Low power CMOS RAM 70H Control Circuitry 71H :::::::::::::::::::::::::::::::::::: INT 7FH
19
Internal Ports 70 – 7FH (16 ports)
Only 70 & 71H are important from programming point of view
20
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
21
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
22
Week Day 01H = Sunday 02H = Monday 03H = Tuesday 04H = Wednesday
05H = Thursday 06H = Friday 07H = Saturday
23
Year No of Century and Year are in BCD.
24
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.
25
Accessing the Battery Powered RAM
outport (0x70, 0); outport (0x70, 4); sec = inport (0x71); outport (0x71,hrs);
26
Status Register A 7 6 5 4 3 2 1 0 Interrupt frequency Time frequency
Interrupt frequency Time frequency 0 = Time is not updated 1 = Time is updated
Similar presentations
© 2024 SlidePlayer.com. Inc.
All rights reserved.