Lecture 9
- Synchronous Devices require a timing signal. Clock generated Interval Timer Microprocessor Interval Timer Clk PCLK = MHz PCLK (for peripheral Synchronous Devices) Clk Ch0 to IRQ0 CH1 TO DRAM controller Ch2 to PC Speaker
Counter Registers: Counter registers can be used to divide frequency. /16 /8 /4 /2 count
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.
Binary = 0 BCD = 1 Mode 0 ~ 5 =000 ~ 101 Ch: 00=0 01=1 10=2 01=Low Byte 10=High Byte 11=Low Byte followed by High Byte
Divisor = 4 Mode = Divisor = 4 Mode = 3 Divisor = 4 Mode = 2 Divisor = 4 Mode = 1
Binary Count: count BCD COUNT=89 99=
Ports & Channels: 3-Channels 16-bit wide divisor value i.e 0~ 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.
Connect to interval timer = 1 Turn ON Speaker = 1 Turn OFF Speaker=0 Rest of the bits are used by other devices and should not be changed. 61H Port
Example: Program loads divisor value of 0x21FF Turns ON the speaker and connects it to Interval Timer #include 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*) 0x C void main() { unsigned long int tx; tx = (*time); tx = tx +18; puts(“Before”); while((*time <= tx); puts(“After”); }