Lecture 17
#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); }
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; } }
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
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
Software Oriented Flow Control Makes use of Two Control characters. XON (^S) XOFF (^T)
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; }
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 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)
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)
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 Control Circuitry 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
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 7 6 5 4 3 2 1 0 Interrupt frequency Time frequency 0 = Time is not updated 1 = Time is updated