1 Homework Reading –Intel 8254 Programmable Interval Timer (PIT) Data Sheet Machine Projects –Continue on MP3 Labs –Continue in labs with your assigned.

Slides:



Advertisements
Similar presentations
Homework Reading Machine Projects Labs
Advertisements

Microprocessor & Interfacing
Parul Polytechnic Institute
PROGRAMMABLE PERIPHERAL INTERFACE -8255
Programmable Interval Timer
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.
I/O Unit.
68HC11 Polling and Interrupts
Interrupts in Protected-Mode Writing a protected-mode interrupt-service routine for the timer-tick interrupt.
1 Homework Reading –Review previous material on “interrupts” Machine Projects –MP4 Due today –Starting on MP5 (Due at start of Class 28) Labs –Continue.
Interrupts What is an interrupt? What does an interrupt do to the “flow of control” Interrupts used to overlap computation & I/O – Examples would be console.
Interrupts in Protected-Mode Writing a protected-mode interrupt-service routine for the timer-tick interrupt.
Homework / Exam Return and Review Exam #1 Reading Machine Projects
Khaled A. Al-Utaibi  Intel Peripheral Controller Chips  Basic Description of the 8255  Pin Configuration of the 8255  Block Diagram.
Interrupts. What Are Interrupts? Interrupts alter a program’s flow of control  Behavior is similar to a procedure call »Some significant differences.
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.
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.
PIT: Programmable Interval Timer
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
ELEC4601 Microprocessor systems Lab 3 Tutorial
The 8253 Programmable Interval Timer
Interrupts and DMA CSCI The Role of the Operating System in Performing I/O Two main jobs of a computer are: –Processing –Performing I/O manage and.
ECE 353 Introduction to Microprocessor Systems Discussion 11.
Timers.
CSNB374: Microprocessor Systems Chapter 5: Procedures and Interrupts.
CE Operating Systems Lecture 2 Low level hardware support for operating systems.
Dec Hex Bin 14 E ORG ; FOURTEEN Interrupts In x86 PC.
8254 Timer.
CE Operating Systems Lecture 2 Low level hardware support for operating systems.
7. IRQ and PIC ENGI 3655 Lab Sessions. Richard Khoury2 Textbook Readings  Interrupts ◦ Section
14.2: x86 PC AND INTERRUPT ASSIGNMENT
Chapter 3 : Top Level View of Computer Functions Basic CPU function, Interconnection, Instruction Format and Interrupt.
Lecture 22: LM3S9B96 Microcontroller – SysTick and General-Purpose Timers.
The 8085 Microprocessor Architecture. What 8085 meant for? 80 - year of invention bit processor 5 - uses +5V for power.
INTERRUPTS. Topics to be discussed  8088/86 Hardware Interrupts pins 8088/86 Hardware Interrupts pins   Pin description Pin description.
Intel 8259A PIC EEE 365 [FALL 2014] LECTURE 21 ATANU K SAHA BRAC UNIVERSITY.
DEPARTMENT OF ELECTRONICS ENGINEERING
Homework Reading Machine Projects
Homework / Exam Return and Review Exam #1 Reading Machine Projects
Homework Reading Machine Projects Labs
Microprocessor and Assembly Language
68HC11 Interrupts & Resets.
Homework Reading Machine Projects Labs
Timer and Interrupts.
Introduction An interrupt is an event which informs the CPU that its service (action) is needed. Sources of interrupts: Internal fault (e.g.. divide by.
Discussions on hw5 Objectives:
8254 – SOFTWARE PROGRAMMABLE TIMER
Homework Reading Labs S&S Extracts ,
Programmable Interval Timer
Programmable Interval Timer
Programmable Interval Timer
Programmable Interval Timer 8254 LECTURE 3
Homework Reading Machine Projects Labs
8259 Chip The Intel 8259 is a family of Programmable Interrupt Controllers (PIC) designed and developed for use with the Intel 8085 and Intel 8086 microprocessors.
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.
Interrupt Driven I/O References Text: Tanenbaum ch.1.4.3, ch Receiver Interrupt Program Example:
8254 Timer and Counter (8254 IC).
Discussions on hw5 Objectives:
Programmable Interval timer 8253 / 8254
8259 Programmable Interrupt Controller
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)
Presentation transcript:

1 Homework Reading –Intel 8254 Programmable Interval Timer (PIT) Data Sheet Machine Projects –Continue on MP3 Labs –Continue in labs with your assigned section

2 Programmable Interval Timer This is just an overview – Read data sheet 8254 VLSI chip with three 16 bit counters Each counter: –Is decremented based on its own input clock –Is only decremented while its gate is active –Generates its own output clock = input clock / count length –Generates an interrupt when count value reaches zero –Automatically reloads initial value when it reaches zero

3 PIT Device (Timer 0) Simplest device: always is interrupting, every time it down counts to zero Can’t disable interrupts in this device! Can mask them off in the PIC We can control how often it interrupts Timer doesn’t keep track of interrupts in progress—just keeps sending them in We don’t need to interact with it in the ISR (but we do need to send an EOI to the PIC)

4 Use of PIT in MP3 We use PIT counter 0 with 18.2 Hz output to generate an interrupt every 55 millisecs ISR increments “tickcount” each time We read the 16 bit counter to get value of the counter at 55 millisec / 64K resolution This gives us resolution of ____ microsecs (You are to figure that out as part of mp3)

5 Use of PIT in MP3 MP3 gives you a start for the required C code in timepack_sapc.c. You add to it. You do not need to write the code for the PIT initialization or the interrupt service routine However, you should study the C code to understand how it works: –Find where code disables and enables interrupts –Find the PIT initialization code –Find the PIT ISR code and see what it does Figure out how to read the count in progress to get the improved resolution required for mp3

6 Timer Interrupt Software Initialization –Disallow interrupts in CPU ( cli ) Unmask IRQ0 in the PIC by ensuring bit 0 is 0 in the Interrupt Mask Register accessible via port 0x21 Set up interrupt gate descriptor in IDT, using irq0inthand Set up timer downcount to determine tick interval –Allow interrupts ( sti ) Shutdown –Disallow interrupts ( cli ) Disallow timer interrupts by masking IRQ0 in the PIC by making bit 0 be 1 in the Mask Register (port 0x21) –Allow interrupts ( sti )

7 Timer Interrupts: Interrupt Handler (Two Parts) irq0inthand – the outer assembly language interrupt handler –Save registers –Calls C function irq0inthandc –Restore registers –Iret irq0inthandc - the C interrupt handler –Issues EOI –Increase the tick count, or whatever is wanted

8 PIT Characteristics PIT chip has four I/O ports assigned to it: A 1 A 0 –Timer 0 assigned port 40 = –Timer 1 assigned port 41 = –Timer 2 assigned port 42 = –Control assigned port 43 = –Chip selected by “chip select” and A 1 -A 0 –Other signals include read, write, and data

9 Control Word Format Actually only a byte: SC1-SC0 select which counter to write/read RW1-RW0 to latch value or select which byte of count value M2-M0 determines which operating mode BCD specifies whether binary or BCD count Command formats found in datasheet SC1SC0RW1RW0M2M1M0BCD

10 Using the PIT in C Refer to timer.h #define TIMER0_COUNT_PORT 0X40 #define TIMER_CNTRL_PORT 0X43 /* bits 6-7: */ #define TIMER0 (O<<6) #define TIMER1 (1<<6) /* Bits 4-5 */ #define TIMER_LATCH (0<<4) #define TIMER_SET_ALL (3<<4) /* Bits 1-3 */ #define TIMER_MODE_RATEGEN (2<<1) /* Bit 0 */ #define TIMER_BINARY_COUNTER 0

11 Programming the PIT Bits to initialize TIMER0 | TIMER_SET_ALL | TIMER_RATEGEN |TIMER_BINARY_COUNTER Output to the timer I/O port outpt(TIMER_CNTRL_PORT, …); Then load the downcount outpt(TIMER0_COUNT_PORT, count & 0xFF); // LSByte outpt(TIMER0_COUNT_PORT, count >> 8); // MSByte

12 What Are the PIT Modes? Mode 0: Count value loaded and countdown occurs on every clock signal; Out from counter remains low until count reaches 0 when it goes high Mode 2: Counts down from loaded value; when count has decremented to 1, OUT goes low for one clock pulse and then goes high again; count is reloaded and process repeats Count = 1Count = 0

13 What Are the PIT Modes? (Cont’d) Mode 3: Functions as a divide by n square wave generator, where n is the count value; OUT starts high and alternates between low and high.

14 PIT Interface to Processor Internal counters are 16 bits (2 bytes) Only 8 pins connected to the data bus Must use a sequence of two one-byte “in” or “out” instructions to transfer full 16 bits Must “latch” count in progress to read a valid 16 bit value only 8 bits at a time Input ClockOutput Clock Borrow Two 1 byte reads (Borrow between?) 88

15 Reading the Count Values Want to read the count value without disturbing the count in progress Have to consider that the counter is changing while we are attempting to read it Best way to read the count is to use the counter latch command to temporarily latch the count outpt(TIMER_CNTRL_PORT, TIMER0 |TIMER_LATCH); count = inpt(TIMER0_COUNT_PORT); count |= (inpt(TIMER0_COUNT_PORT) << 8); Reading the count lets the latch again follow the count

16 Converting Counts to Real Time Can count from 1 to 64K, that is from approximately one microsecond to 55 milliseconds What if we want something longer than that? –Have to perform repeated counts Example: 200 milliseconds = 3 * Would need three full counts (called ticks) plus a partial count (called downcounts) –But how do you know when a tick has occurred? Could poll the device Better to use an interrupt –If interrupt occurs on every tick, which is counted, then the elapsed time in microseconds is approximately: [#ticks * (startcount - stopcount)]/1.193

17 Measuring the Time Interval Given –Event A happens 35K downcounts before tick 201 –Event B happens 43K downcounts before tick 203 How much time has elapsed? Graphically: Elapsed time = 202 ticks + (65K – 43K) downcounts - (200 ticks + (65K – 35K) downcounts) = 2 ticks – 8K down counts (where 1 tick = 64 * 1K down counts) Tick 200 Tick 201 Tick 202 Tick K down counts left 43K down counts left

18 Main Memory Access One bus cycle per memory read or write Calculating bus cycles: Instructions fetched 8 bytes at a time –Average: one eighth of a bus cycle per byte of an instruction Data reads/writes – byte, word, or long word at a time –movl %eax, %edx reg/reg instruction(2 bytes).25R –movl %eax, total reg/mem instruction* (5 bytes) 0.625R+1W –movl %edx, total reg/mem instruction(6 bytes) 0.75R+1W *eax as accumulator is special case

19 Cache Memory Located between CPU and main memory –Holds a copy of most recently accessed data L1 cache implemented with “hidden” registers –Not visible to assembly language programmer L2 cache implemented with SRAM memory –Faster access than DRAM main memory –Typically larger than L1 cache Either cache speeds up access to most recently and frequently accessed memory locations Avoids a bus cycle to main memory when data is found in cache (“cache hit”)

20 Cache Memory Processor Control Bus (M/IO#, W/R# and D/C# Signals) Address Bus Main Memory (DRAM) I/O Devices Data Bus “Regular” Registers Fetch and Execute Control L2 Cache (SRAM) L1 Cache (“Hidden” Registers)