PIT: Programmable Interval Timer

Slides:



Advertisements
Similar presentations
Lecture 08: 8253/4 Timer and Music
Advertisements

Microprocessor & Interfacing
The 8051 Microcontroller and Embedded Systems
1 Homework Reading –Intel 8254 Programmable Interval Timer (PIT) Data Sheet Machine Projects –Continue on MP3 Labs –Continue in labs with your assigned.
PROGRAMMABLE PERIPHERAL INTERFACE -8255
Dr A Sahu Dept of Comp Sc & Engg. IIT Guwahati I/O + Timer 8155 I/O + Timer 8255 I/O 8255 I/O 8253/54 Timer 8253/54 Timer 2 Port (A,B), No Bidirectional.
Dr A Sahu Dept of Computer Science & Engineering IIT Guwahati.
Programmable Interval Timer
Dr A Sahu Dept of Computer Science & Engineering IIT Guwahati.
8253/54 Timer Section /54 Timer Description and Initialization
Using the 8254 Timer-Counter Understanding the role of the system’s 8254 programmable Interval-Timer/Counter.
Programmable Interval Timer Prepared By: Prof. M. B. Salunke SITS, Narhe, Pune - 41.
The 8085 Microprocessor Architecture
Microprocessor and Microcontroller
Direct Memory Access Introduction to 8237
Engineering 4862 Microprocessors Lecture 24
1 TK2633TK Microprocessor Architecture DR MASRI AYOB.
P Address bus Data bus Read-Only Memory (ROM) Read-Write Memory (RAM)
8254 Modes Made by: Ryan wahab (8) Modes Gate is low the count will be paused Gate is high Will continue counting Mode 0: An events counter.
DEEPAK.P MICROPROCESSORS AND APPLICATIONS Mr. DEEPAK P. Associate Professor ECE Department SNGCE 1.
1.  8051 Timers “count up,” incrementing the Timer’s respective “count register” each time there is a triggering clock pulse. 2  When the “count register”
The 8051 Microcontroller architecture
Khaled A. Al-Utaibi  8086 Pinout & Pin Functions  Minimum & Maximum Mode Operations  Microcomputer System Design  Minimum Mode.
Khaled A. Al-Utaibi  Intel Peripheral Controller Chips  Basic Description of the 8255  Pin Configuration of the 8255  Block Diagram.
CHAPTER TIMER PROGRAMMING Timers The 8051 has two timers/counters, they can be used as ◦ Timers to generate a time delay ◦ Event counters.
Lecture 9. - Synchronous Devices require a timing signal. Clock generated Interval Timer Microprocessor Interval Timer Clk PCLK = MHz PCLK (for.
8254 Programmable Interval Timer
ENEE 440 Chapter Timer 8254 Register Select The 8254 timer is actually 3 timers in one. It is an upgraded version of the 8253 timer which was.
1 Chapter 4 Timer Operation (I. Scott MacKenzie).
Engineering 4862 Microprocessors Lecture 27 Cheng Li EN-4012
7/23 Timers in Coldfire Processor Computer Science & Engineering Department Arizona State University Tempe, AZ Dr. Yann-Hang Lee (480)
Dec Hex Bin 13 D ORG ; THIRTEEN 8253/54 Timer.
8253 TIMER. Engr 4862 Microprocessors 8253 / 8254 Timer A.k.a. PIT (programmable Interval Timer), used to bring down the frequency to the desired level.
8254 Counter/Timer Counter Each of the three counter has 3 pins associated CLK: input clock frequency- 8 MHz OUT GATE: Enable (high) or disable.
8254 SOFTWARE PROGRAMMABLE TIMER/COUNTER
The 8253 Programmable Interval Timer
MICROPROCESSOR INPUT/OUTPUT
PIT Programming Examples Working with the modes of PIT.
Timers.
Advanced Microprocessor1 I/O Interface Programmable Interval Timer: 8254 Three independent 16-bit programmable counters (timers). Each capable in counting.
8279 KEYBOARD AND DISPLAY INTERFACING
University of Tehran 1 Microprocessor System Design Timers Omid Fatemi
8254 Timer.
8279 KEYBOARD AND DISPLAY INTERFACING
Programmable Interrupt Controller (PIC)
8086 – I/O Interfacing - I/O mapped I/O
HJD Institute of Technical Education & Research- Kera(Kutch) The 8051 Microcontroller architecture PREPARED BY: RAYMA SOHIL( )
8254 SOFTWARE PROGRAMMABLE TIMER/COUNTER. Difference between 8253 and Maximum input clock frequency is 2.6 MHz Maximum input clock frequency.
8253 / 8254 Timer A.k.a. PIT (programmable Interval Timer), used to bring down the frequency to the desired level Three counters inside 8253/8254. Each.
Homework Reading Machine Projects Labs
8254 – SOFTWARE PROGRAMMABLE TIMER
Programmable Interval Timer
Programmable Interval Timer
Programmable Interval Timer
Programmable Interval Timer 8254 LECTURE 3
8085 Microprocessor Architecture
8253 Timer In software programming of 8085, it has been shown that a delay subroutine can be programmed to introduce a predefined time delay. The delay.
An Introduction to Microprocessor Architecture using intel 8085 as a classic processor
EMT 348: Microcontroller Timer/counter
Introduction to Micro Controllers & Embedded System Design Timer Operation Department of Electrical & Computer Engineering Missouri University of Science.
8254 Timer and Counter (8254 IC).
Timer.
Timers.
Programmable Interval timer 8253 / 8254
8085 Microprocessor Architecture
Programmable Interval timer 8253 / 8254
8253 – PROGRAMMABLE INTERVAL TIMER (PIT). What is a Timer? Timer is a specialized type of device that is used to measure timing intervals. Timers can.
Programmable Interrupt Controller (PIC)
Programmable Interval Timer
Presentation transcript:

PIT: Programmable Interval Timer Introduction to 8253/8254

8253/54 Timer Timer Description and Initialization PIT (programmable Interval Timer) The 8253 chip was used in the IBM PC/XT, but starting with the IBM PC/AT, the 8254 replaced the 8253. 8253 and 8254 have exactly the same pinout. 8254 is a superset of the 8253.

Programmable Interval Timer - 8254

Pin Diagram

Pin Description of 8253/54 A0, A1, and CS Inside the 8253/54 timer, there are 3 counters. Each timer works independently and programmed separately. Each counter is assigned an individual port address. The control register common to all 3 counters and has its own port.

CLK CLK is the input clock frequency, which can range between 0 and 2 MHz for the 8253. For input frequencies higher than 2 MHz, the 8254 must be used. The 8254 can go as high as 8 MHz, and 8254-2 can go 10 MHz. OUT Can have square-wave, one-shot, and other square-shape waves for various duty cycles but no sine-wave or saw-tooth shapes. Gate This pin is used to enable or disable the counter.

D0-D7 The D0-D7 data bus of the 8253/54 is a bidirectional bus connected to D0-D7 of the system data bus. RD and WR are connected to IOR and IOW control signals of the system bus. Initialization of the 8253/54 Each of the three counters of the 8253/54 must be programmed separately. The 8253/54 must be initialized before it is used.

Control word The figure shows the one-byte control word of the 8253/54. D0 chooses between a binary number divisor of 0000 to FFFFH or a BCD divisor of 0000 to 9999H. The highest number is 216 for binary and 104 for BCD. To get the highest count, the counter is loaded with zeros. D1, D2, and D3 are for mode selection.

D4 and D5 are for RL0 and RL1 RL0 and RL1 are used to indicate the size of the divisor, and have 3 options: Read/write MSB only Read/write LSB only Read/write LSB first followed immediately by the MSB.

Operation Modes Mode 0 Interrupt on terminal count Mode 1 Programmable one-shot Mode 2 Rate Generator Mode 3 Square wave rate generator Mode 4 Software triggered strobe Mode 5 Hardware trigger strobe

All counters are down counters. D6 and D7 are used to select the 3 counters, counter 0, counter 1, or counter 2, is to be initialized by the control byte. To program a given counter of the 8253/54 to divide the CLK input frequency one must send the divisor to that specific counter’s reg. To divide the frequency by 10000 (BCD) or 65536 (binary) we must send in 0 for both high and low bytes.

IBM PC 8253/54 Timer Connections and Programming

PCLK of the 8284 is 2.3863663 MHz and must be divided by 2. The three clocks of the 8253, CLK0, CLK1, and CLK2, are all connected to a constant frequency of 1.1931817 MHz. PCLK of the 8284 is 2.3863663 MHz and must be divided by 2. GATE0 and GATE1 enable counter0 and counter 1 respectively. GATE2 of counter 2 can be enabled or disabled through PB0 of port B of the 8255.

Using counter 0 CLK0 of counter 0 is 1.193 MHz, and GATE0 is connected permanently. OUT0 is connected to IRQ0 of the 8259 interrupt controller to provide time-of-day (TOD) interrupt. IRQ0 is activated 18.2 times per second. (18.2 Hz) The counter must to divide 1.193 MHz by 65,536.

Using counter 0 D0 = 0 for the binary value. D3 D2 D1 = 011, mode 3 The wave shape is a square wave. D0 = 0 for the binary value. D3 D2 D1 = 011, mode 3 D4 D5 = 11, for reading/writing the LSB first, followed by MSB. D7 D6 = 00, for counter 0.

Using counter 0 The function of IR0 is not only taking care of the TOD clock. BIOS will make this interrupt available by going to the vector table of INT 1CH.

Using Counter 1 In counter 1, CLK1 is connected to 1.193 MHz and GATE is high. OUT1 generates a periodic pulse required to refresh DRAM memory of the computer. The refreshing must be done at least 15s (66278Hz) for each cell, and is performed by DMA. Counter must divide the input frequency 1.19318 MHz by 18. DRAM maximum frequency refresh time is 2 ms.

Using Counter 1 D0 = 0 for binary option D3 D2 D1 = 010, for mode 2 shape output. D5 D4 = 01, for LSB only D7 D6, for counter 1. D7~D0 = 0101 0100 = 54H for the control word.

Using Counter 2 The output of counter 2 is connected to two different devices: the speaker and PC5 of the 8255. Use of timer 2 by the speaker In the IBM PC, CLK2 is connected to a frequency of 1.19318 MHz and GATE2 is programmed by PB0 of port 61H (port B). The IBM PC uses counter 2 to generate the beep sound. The beep sound has a frequency of 896 Hz (divisor = 1331)

Turning on the speaker via PB0 and PB1 of port 61H The process of turning on the speaker is the same for all IBM PCs and compatibles from 8088-based to 80486 and Intel’s Pentium-based systems. Gate2 must be high to provide the CLK to timer 2. This function is performed by PB0 of port 61H. The following is the code to turn the speaker on.

Turning on the speaker via PB0 and PB1 of port 61H

Time delay for 80x86 PCs Creating time delays in 8088/86-based PC/XT, PS2, and compatibles MOV CX, N AGAIN: LOOP AGAIN The above codes can be used to generate delays (N  T 17 seconds) Approximate delay time The delay is not only frequency dependent but also CPU dependent. IBM provides a scheme to create a time delay using hardware that is not only frequency but also CPU independent.

Time delays in 80x86 IBM PC The following method of creating hardware time delays was first implemented in the IBM PC and compatible computers. To create a processor independent delay, IBM made PB4 of port 61H toggle every 15.085s. CS holds 15.085s in the following codes.

Time delays in 80x86 IBM PC

Time delays in 80x86 IBM PC Now a time delay of any duration can be created regardless of the CPU frequency as long as it is a 286 and higher PC. For example set CX=33144 (3314415.085s=0.5 second) MOV CX, 33144 CALL WAITF

Time delays in 80x86 IBM PC

Example

Examples

Generating Music on the IBM PC As mentioned earlier, counter 2 is connected to the speaker and it can be programmed to output any frequency that is desired. Look at the list of piano notes and their frequencies given in Fig. 5-5. Music: frequency and time duration

A delay of 250 ms

Shape of 8253/54 Outputs

Out0 pulse shape in IBM BIOS IBM BIOS programmed counter 0 to create mode 3, which is square-wave shape. Counter 0 is loaded with the number 65,536 and the clock period of input frequency 838 ns (1/1.193 MHz = 838 ns), so the period of the OUT0 pulse is equal to 65536838 ns = 54.9 ms (18.2 Hz). OUT0 continuously sends out square wave pulses.

Out1 pulse shape in the IBM BIOS IBM BIOS programmed counter 1 in mode 2, rate generator, with the value 18 loaded into the counter. OUT1 will be high for a total of 17 838 ns and go low for one pulse of 838 ns GATE1 is set to 1 permanently

OUT2 pulse shape in the IBM BIOS IBM BIOS loads the value 1331 into counter 2. Since 1331 is an odd number, the OUT2 pulse is high for a total of (1331+1)/2 = 666  838 ns and is low for a total of (1331-1)/2 = 665  838 ns

Mode 0: interrupt on terminal count The output in this mode is initially low, and will remain low for the duration of the count if GATE = 1. Width of low pulse = NT Where N is the the clock count loaded into counter, and T is the clock period of the CLK input.

Mode 0: interrupt on terminal count When the terminal count is reached, the output will go high and remain high until a new control word or new count number is loaded. In this mode, if GATE input becomes low at the middle of the count, the count will stop and the output will be low. The count resumes when the gate becomes high again. This in effect adds to the total time the output is low.

Mode 1: programmable one-shot This mode is also called hardware triggerable one-shot. The triggering must be done through the GATE input by sending a 0-to-1 pulse to it. The following two steps must be performed: Load the count registers. A 0-to-1 pulse must be sent to the GATE input to trigger the counter. Contrast this with mode 0, in which the counter produces the output immediately after the counter is loaded as long as GATE = 1. In mode 1 after sending the 0-to-1 pulse to GATE, OUT becomes low and stays low for a duration of NT, then becomes high and stays high until the gate is triggered again.

Mode 2: rate generator Mode 2 is also called divide-by-N counter. In this mode, if GATE = 1, OUT will be high for the NT clock period, goes low for only one clock pulse, then the count is reloaded automatically, and the process continues indefinitely.

Mode 3: square wave rate generator In this mode if GATE = 1, OUT is a square wave where the high pulse is equal to the low pulse if N is an even number. In this case the high part and low part of the pulse have the same duration and are equal to (N/2)T (50% duty cycle) If N is an odd number, the high pulse is one clock pulse longer. This mode is widely used as a frequency divider and audio-tone generator.

Mode 4: software trigger strobe In this mode if GATE = 1, the output will go high upon loading the count. It will stay high for the duration of NT. After the count reaches zero (terminal count), it becomes low for one clock pulse, then goes high again and stays high until a new command word or new count is loaded. To repeat the strobe, the count must be reloaded again. Mode 4 is similar to mode 2, except that the counter is not reloaded automatically. In this mode, the count starts the moment the count is written into the counter.

Mode 5: hardware trigger strobe This mode is similar to mode 4 except that the trigger must be done with the GATE input. In this mode after the count is loaded, we must send a low-to-high pulse to the gate to start the counter.