Presentation is loading. Please wait.

Presentation is loading. Please wait.

Lecture 9. - Synchronous Devices require a timing signal. Clock generated Interval Timer Microprocessor Interval Timer Clk PCLK =1.19318 MHz PCLK (for.

Similar presentations


Presentation on theme: "Lecture 9. - Synchronous Devices require a timing signal. Clock generated Interval Timer Microprocessor Interval Timer Clk PCLK =1.19318 MHz PCLK (for."— Presentation transcript:

1 Lecture 9

2 - Synchronous Devices require a timing signal. Clock generated Interval Timer Microprocessor Interval Timer Clk PCLK =1.19318 MHz PCLK (for peripheral Synchronous Devices) Clk Ch0 to IRQ0 CH1 TO DRAM controller Ch2 to PC Speaker

3 Counter Registers: Counter registers can be used to divide frequency. /16 /8 /4 /2 count 7 6 5 4 3 2 1 0

4 0000 0000 0001 0000 0010 0000 0011 0000 0100 0000 0101 0000 0110 0000 0111 0000 1000 0000 1001 0000 1010 0000 1011 0000 1100 0000 1101 0000 1110 0000 1111

5 Timing Diagram Bit 0 (/2) Bit 1 (/4) Bit 2 (/8) Bit 3 (/16) : : : : :

6 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 10110100 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 7 6 5 4 3 2 1 0

8 Divisor = 4 Mode = 4 -----3----- -----4----- ---2--- -----4----- Divisor = 4 Mode = 3 Divisor = 4 Mode = 2 Divisor = 4 Mode = 1

9 10001001 10001001 1 0 0 1 0 0 0 0 1 0 0 0 1 0 1 0 1 0 0 0 1 0 1 1 1 0 0 1 0 0 0 1 1 0 0 1 0 0 0 0 Binary Count: count BCD COUNT=89 99=

10 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

11 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.

12 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

13 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); }

14 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”); }


Download ppt "Lecture 9. - Synchronous Devices require a timing signal. Clock generated Interval Timer Microprocessor Interval Timer Clk PCLK =1.19318 MHz PCLK (for."

Similar presentations


Ads by Google