140 likes | 215 Views
Lecture 9. - Synchronous Devices require a timing signal. Interval Timer. Clock generated. Microprocessor. Clk. Clk. PCLK =1.19318 MHz. Ch0 to IRQ0. Interval Timer. Clk. CH1 TO DRAM controller. PCLK (for peripheral Synchronous Devices). Ch2 to PC Speaker. Counter Registers:.
E N D
- Synchronous Devices require a timing signal. Interval Timer Clock generated Microprocessor Clk Clk PCLK =1.19318 MHz Ch0 to IRQ0 Interval Timer Clk CH1 TO DRAM controller PCLK (for peripheral Synchronous Devices) Ch2 to PC Speaker
Counter Registers: • Counter registers can be used to divide frequency. 7 6 5 4 3 2 1 0 count /16 /8 /4 /2
0000 1000 0000 1001 0000 1010 0000 1011 0000 1100 0000 1101 0000 1110 0000 1111 0000 0000 0000 0001 0000 0010 0000 0011 0000 0100 0000 0101 0000 0110 0000 0111
Timing Diagram Bit 0 (/2) Bit 1 (/4) Bit 2 (/8) Bit 3 (/16) : : : : : : : : : : : : : : :
Interval Timer Programming: Command Registers • 8-bit Command port • Need to be programmed before loading the divisor value for a channel. • 3 channels, each requires a 16-bit divisor value to generate the output frequency.
7 6 5 4 3 2 1 0 Binary = 0 BCD = 1 Ch: 00=0 01=1 10=2 Mode 0 ~ 5 =000 ~ 101 01=Low Byte 10=High Byte 11=Low Byte followed by High Byte
Divisor = 4 Mode = 1 -----4----- -----4----- Divisor = 4 Mode = 2 -----3----- -----3----- Divisor = 4 Mode = 3 ---2--- ---2--- Divisor = 4 Mode = 4 -----4----- -----4-----
Binary Count: count 1 0 0 0 1 0 1 0 1 0 0 0 1 0 1 1 BCD COUNT=89 1 0 0 1 0 0 0 0 1 0 0 1 0 0 0 1 1 0 0 1 1 0 0 1 99= 0 0 0 0 0 0 0 0
Ports & Channels: • 3-Channels 16-bit wide divisor value i.e 0~65535 8-bit port for each channel therefore the divisor word is loaded serially byte by byte. Port Addresses 43H = Command Port 40H = 8-bit port for Channel 0 41H = 8-bit port for Channel 1 42H = 8-bit port for Channel 2
Programming Concepts for Interval Timer: • Load the Command byte into command register required to program the specific channel. • The divisor word is then Serially loaded byte by byte.
61H Port Connect to interval timer = 1 Rest of the bits are used by other devices and should not be changed. Turn ON Speaker = 1 Turn OFF Speaker=0
Example: Program loads divisor value of 0x21FF Turns ON the speaker and connects it to Interval Timer #include<BIOS.H> #include<DOS.H> void main() { outportb (0x43,0xB4); outportb (0x42,0xFF); outportb (0x42,0x21); outportb (0x61,inportb(0x61) | 3); getch(); outportb (0x61,inportb(0x61) & 0xFC); }
Timer Count: 40:6CH Incremented every 1/18.2 seconds. Whenever INT8 unsigned long int far *time = unsigned long int far*) 0x0040006C void main() { unsigned long int tx; tx = (*time); tx = tx +18; puts(“Before”); while((*time <= tx); puts(“After”); }