interfacing peripheral ics and their chapter 7 · priority resolver mode set register 16-bit ......

42
Chapter 7 Peripheral ICs and their Interfacing

Upload: phamtuyen

Post on 03-Apr-2018

227 views

Category:

Documents


4 download

TRANSCRIPT

Page 1: Interfacing Peripheral ICs and their Chapter 7 · Priority Resolver mode set register 16-bit ... Programming the 8257 Mode and sending commands to 8257 A3 = 0 for selecting a channel’s

Chapter 7

Peripheral ICs and their Interfacing

Page 2: Interfacing Peripheral ICs and their Chapter 7 · Priority Resolver mode set register 16-bit ... Programming the 8257 Mode and sending commands to 8257 A3 = 0 for selecting a channel’s

Ch07L3 -"Microcontrollers.........", Raj Kamal, Pearson Education, 2005

Lesson 3

8257- DMA Controller

Page 3: Interfacing Peripheral ICs and their Chapter 7 · Priority Resolver mode set register 16-bit ... Programming the 8257 Mode and sending commands to 8257 A3 = 0 for selecting a channel’s

Ch07L3 -"Microcontrollers.........", Raj Kamal, Pearson Education, 2005

Outline

• Three Transaction Methods for Peripheral IOs

• DMAC and 8257 DMAC• 8257 Block Diagram, Pins and

Interfacing• 8257 Programming

Page 4: Interfacing Peripheral ICs and their Chapter 7 · Priority Resolver mode set register 16-bit ... Programming the 8257 Mode and sending commands to 8257 A3 = 0 for selecting a channel’s

Ch07L3 -"Microcontrollers.........", Raj Kamal, Pearson Education, 2005

Three Transaction Methods• Programmed IOs (like 8255 port used

without handshake and Intr signals)• Interrupt Driven IOs (like 8255 port

used without handshake and Intr signals)

• DMA Transactions using a DMAC

Page 5: Interfacing Peripheral ICs and their Chapter 7 · Priority Resolver mode set register 16-bit ... Programming the 8257 Mode and sending commands to 8257 A3 = 0 for selecting a channel’s

Ch07L3 -"Microcontrollers.........", Raj Kamal, Pearson Education, 2005

Busy-wait IOs (transactions) Example

wait

byte not available

byte available and not last one

Read next

Readcheck buffer status

Last

Next

Page 6: Interfacing Peripheral ICs and their Chapter 7 · Priority Resolver mode set register 16-bit ... Programming the 8257 Mode and sending commands to 8257 A3 = 0 for selecting a channel’s

Ch07L3 -"Microcontrollers.........", Raj Kamal, Pearson Education, 2005

Busy-wait IOs (transactions) Example

wait

Full

not full and not last byte

write next

writecheck buffer status

Last

Next

Page 7: Interfacing Peripheral ICs and their Chapter 7 · Priority Resolver mode set register 16-bit ... Programming the 8257 Mode and sending commands to 8257 A3 = 0 for selecting a channel’s

Ch07L3 -"Microcontrollers.........", Raj Kamal, Pearson Education, 2005

Interrupt driven IOs Example

Interrupt

byte available

Readnot last one

Last

Next

Page 8: Interfacing Peripheral ICs and their Chapter 7 · Priority Resolver mode set register 16-bit ... Programming the 8257 Mode and sending commands to 8257 A3 = 0 for selecting a channel’s

Ch07L3 -"Microcontrollers.........", Raj Kamal, Pearson Education, 2005

Interrupt driven IOs Example

Interrupt

byte for write available

writenot last one

Last

Next

Page 9: Interfacing Peripheral ICs and their Chapter 7 · Priority Resolver mode set register 16-bit ... Programming the 8257 Mode and sending commands to 8257 A3 = 0 for selecting a channel’s

Ch07L3 -"Microcontrollers.........", Raj Kamal, Pearson Education, 2005

• Controller or server sends hold request for processor to grant on acknowledgement, the access to address and data buses, IORD, IOWR, MEMRD, MEMWR and IO buses

Direct Memory Access Control (Peripheral Transactions Server) IOs

Page 10: Interfacing Peripheral ICs and their Chapter 7 · Priority Resolver mode set register 16-bit ... Programming the 8257 Mode and sending commands to 8257 A3 = 0 for selecting a channel’s

Ch07L3 -"Microcontrollers.........", Raj Kamal, Pearson Education, 2005

• Once programmed for address of RAM block for transfer and for data counts of IO transactions with RAM, interrupts only at the end of a block transaction or last transaction

Direct Memory Access Control (Peripheral Transactions Server)

Page 11: Interfacing Peripheral ICs and their Chapter 7 · Priority Resolver mode set register 16-bit ... Programming the 8257 Mode and sending commands to 8257 A3 = 0 for selecting a channel’s

Ch07L3 -"Microcontrollers.........", Raj Kamal, Pearson Education, 2005

DMA Transactions (IOs) Example

No ack

yesDMAC Hold

request

By DMAC, Direct Transfer from RAM programmed number of bytes to IO bus

check hold ack Last

InterruptNot last

To Processor

From Processor

Page 12: Interfacing Peripheral ICs and their Chapter 7 · Priority Resolver mode set register 16-bit ... Programming the 8257 Mode and sending commands to 8257 A3 = 0 for selecting a channel’s

Ch07L3 -"Microcontrollers.........", Raj Kamal, Pearson Education, 2005

DMA Transactions (IOs) Example

No ack

yesDMAC Hold

request

By DMAC, Direct Transfer to RAM programmed number of bytes from IO bus

check hold ack Last

Interrupt Not last

To Processor

From Processor

Page 13: Interfacing Peripheral ICs and their Chapter 7 · Priority Resolver mode set register 16-bit ... Programming the 8257 Mode and sending commands to 8257 A3 = 0 for selecting a channel’s

Ch07L3 -"Microcontrollers.........", Raj Kamal, Pearson Education, 2005

Outline

• Three Transaction Methods for Peripheral IOs

• DMAC and 8257 DMAC• 8257 Block Diagram, Pins and

Interfacing• 8257 Programming

Page 14: Interfacing Peripheral ICs and their Chapter 7 · Priority Resolver mode set register 16-bit ... Programming the 8257 Mode and sending commands to 8257 A3 = 0 for selecting a channel’s

Ch07L3 -"Microcontrollers.........", Raj Kamal, Pearson Education, 2005

DMAC and Processor buses

INTR

Ack

ProcessorDMA

Controller

RAM

IO busData bus

Address bus

Hold

MEMRD

IO Device/ Peripheral

IOWRIORD

MEMWR

to RAM

Page 15: Interfacing Peripheral ICs and their Chapter 7 · Priority Resolver mode set register 16-bit ... Programming the 8257 Mode and sending commands to 8257 A3 = 0 for selecting a channel’s

Ch07L3 -"Microcontrollers.........", Raj Kamal, Pearson Education, 2005

DMAC (DMA Controller)Peripheral Transactions Server ack

memory address

DMA Controller/

PTS

RAM

DC MAR

At start, write the DMAC DC register and MAR address of RAM memory block

data count

IO Device/ Peripheral

hold

Page 16: Interfacing Peripheral ICs and their Chapter 7 · Priority Resolver mode set register 16-bit ... Programming the 8257 Mode and sending commands to 8257 A3 = 0 for selecting a channel’s

Ch07L3 -"Microcontrollers.........", Raj Kamal, Pearson Education, 2005

DMAC (DMA Controller)

Ack

AckDMAC Hold

requestDMA

Controller

RAM

IO busData bus At end interrupt on block or last transfer to processor

To Processor

From Processor

IO Device/ Peripheral

Page 17: Interfacing Peripheral ICs and their Chapter 7 · Priority Resolver mode set register 16-bit ... Programming the 8257 Mode and sending commands to 8257 A3 = 0 for selecting a channel’s

Ch07L3 -"Microcontrollers.........", Raj Kamal, Pearson Education, 2005

• Four channels• Priority Resolution support• TC output and Mark output

(after 126 bytes transfer) for interrupts to processor for attention

8257 Four Channel DMAC Features

Page 18: Interfacing Peripheral ICs and their Chapter 7 · Priority Resolver mode set register 16-bit ... Programming the 8257 Mode and sending commands to 8257 A3 = 0 for selecting a channel’s

Ch07L3 -"Microcontrollers.........", Raj Kamal, Pearson Education, 2005

• Auto-load on TC mode support for repeat transactions without reprogramming TC and MAR and mode

• TTL level inputs/outputs compatible with INTEL families

... 8257 Four Channel DMAC Features

Page 19: Interfacing Peripheral ICs and their Chapter 7 · Priority Resolver mode set register 16-bit ... Programming the 8257 Mode and sending commands to 8257 A3 = 0 for selecting a channel’s

Ch07L3 -"Microcontrollers.........", Raj Kamal, Pearson Education, 2005

Outline

• Three Transaction Methods for Peripheral IOs

• DMAC and 8257 DMAC• 8257 Block Diagram, Pins and

Interfacing• 8257 Programming

Page 20: Interfacing Peripheral ICs and their Chapter 7 · Priority Resolver mode set register 16-bit ... Programming the 8257 Mode and sending commands to 8257 A3 = 0 for selecting a channel’s

Ch07L3 -"Microcontrollers.........", Raj Kamal, Pearson Education, 2005

8257

16-bit Address counter

Ch 0,1, 2 and 3

16-bit Address counter

16-bit Address counter

RD/WR control logic

control logic

Data Buffer

Priority Resolver

mode set register

16-bit Address counter

Page 21: Interfacing Peripheral ICs and their Chapter 7 · Priority Resolver mode set register 16-bit ... Programming the 8257 Mode and sending commands to 8257 A3 = 0 for selecting a channel’s

Ch07L3 -"Microcontrollers.........", Raj Kamal, Pearson Education, 2005

8257 VCC

A7-A4

CS

MEMRDIORD

DACK0, 1

D0-D4

GND

D5-D7

MEMWRA3,A2, A1,A0

IOWR

Mark,RDY

Pins12-19CLK, Reset, DACK2, 3, DRQ3, 2, 1, 0

HLDA

HLDADSSTB,AEN

TC (INTR)

Page 22: Interfacing Peripheral ICs and their Chapter 7 · Priority Resolver mode set register 16-bit ... Programming the 8257 Mode and sending commands to 8257 A3 = 0 for selecting a channel’s

Ch07L3 -"Microcontrollers.........", Raj Kamal, Pearson Education, 2005

Table 7.15 - Each Pin signalsTable 7.14 - Block Functions

Page 23: Interfacing Peripheral ICs and their Chapter 7 · Priority Resolver mode set register 16-bit ... Programming the 8257 Mode and sending commands to 8257 A3 = 0 for selecting a channel’s

Ch07L3 -"Microcontrollers.........", Raj Kamal, Pearson Education, 2005

8257

CS

RD,WRD0 to D7A0,A1

Decoder

(WR, IOWR) and (RD, IORD)

Hold

Mark

A0-A3

Reset,RDY

HLDATC

Latch

AD0 to AD7

A0 to An

ALE

A4-A7

DACK0 to 3

DRQ0 to 3

ADSTBAEN

A4- A

n

Page 24: Interfacing Peripheral ICs and their Chapter 7 · Priority Resolver mode set register 16-bit ... Programming the 8257 Mode and sending commands to 8257 A3 = 0 for selecting a channel’s

Ch07L3 -"Microcontrollers.........", Raj Kamal, Pearson Education, 2005

Figure 7.13 for details

Page 25: Interfacing Peripheral ICs and their Chapter 7 · Priority Resolver mode set register 16-bit ... Programming the 8257 Mode and sending commands to 8257 A3 = 0 for selecting a channel’s

Ch07L3 -"Microcontrollers.........", Raj Kamal, Pearson Education, 2005

Outline

• Three Transaction Methods for Peripheral IOs

• DMAC and 8257DMAC• 8257 Block Diagram, Pins and

Interfacing• 8257 Programming

Page 26: Interfacing Peripheral ICs and their Chapter 7 · Priority Resolver mode set register 16-bit ... Programming the 8257 Mode and sending commands to 8257 A3 = 0 for selecting a channel’s

Ch07L3 -"Microcontrollers.........", Raj Kamal, Pearson Education, 2005

Programming the 8257 Mode and sending commands to 8257

When CS = 0,, and IOWR = 0 and A3-A2-A1-A0 = 0000, ... 1111then 8257 gets Mode/Command bytes or channel TC and DMA access MAR

Page 27: Interfacing Peripheral ICs and their Chapter 7 · Priority Resolver mode set register 16-bit ... Programming the 8257 Mode and sending commands to 8257 A3 = 0 for selecting a channel’s

Ch07L3 -"Microcontrollers.........", Raj Kamal, Pearson Education, 2005

Programming the 8257 Mode and sending commands to 8257

A3 = 0 for selecting a channel’s address and TC registers

Each channel has 16 bit register with an access address (write LSB and then MSB at that address to program that ) Each channel has 16 bit register for TC register (written LSB and then MSB)

Page 28: Interfacing Peripheral ICs and their Chapter 7 · Priority Resolver mode set register 16-bit ... Programming the 8257 Mode and sending commands to 8257 A3 = 0 for selecting a channel’s

Ch07L3 -"Microcontrollers.........", Raj Kamal, Pearson Education, 2005

Programming the 8257 Mode and sending commands to 8257

0000 means ch0 MAR address, 0001TC address

0010 means ch1 MAR address, 0011TC address

0100 means ch2 MAR address, 0101TC address

0110 means ch1 MAR address, 0111TC address

Page 29: Interfacing Peripheral ICs and their Chapter 7 · Priority Resolver mode set register 16-bit ... Programming the 8257 Mode and sending commands to 8257 A3 = 0 for selecting a channel’s

Ch07L3 -"Microcontrollers.........", Raj Kamal, Pearson Education, 2005

Programming and reading the 8257 Mode and status

A3 = 1 IOWR = 0 for selecting mode select register

A3 = 1, IORD = 0 for selecting status register

Page 30: Interfacing Peripheral ICs and their Chapter 7 · Priority Resolver mode set register 16-bit ... Programming the 8257 Mode and sending commands to 8257 A3 = 0 for selecting a channel’s

Ch07L3 -"Microcontrollers.........", Raj Kamal, Pearson Education, 2005

Mode Select Register [A3A2A1A0 = 1000]

b1 0 disables ch1, 1 enables ch1

1. b0 0 disables ch0, 1 enables ch0

b3 0 disables ch3, 0 enables ch3

2. b4 = 0 disable rotating priority, 1 enable

b2 0 disables ch2, 1 enables ch2

3. b5 =0 disable extended write 1 enable extended write (next DMA repeat after TC

Page 31: Interfacing Peripheral ICs and their Chapter 7 · Priority Resolver mode set register 16-bit ... Programming the 8257 Mode and sending commands to 8257 A3 = 0 for selecting a channel’s

Ch07L3 -"Microcontrollers.........", Raj Kamal, Pearson Education, 2005

..Mode Select Register [A3A2A1A0 = 1000]

4. b6 0 disable terminal counter and 1 enable (stop or start DMA service)5. b7 =0 disable auto reload (of TC register and MAR of the not disabled channels 1 enable extended write (next DMA repeat after TC

Page 32: Interfacing Peripheral ICs and their Chapter 7 · Priority Resolver mode set register 16-bit ... Programming the 8257 Mode and sending commands to 8257 A3 = 0 for selecting a channel’s

Ch07L3 -"Microcontrollers.........", Raj Kamal, Pearson Education, 2005

Sequential order of Bytes after reset1. Internal registers TC and MAR of each channel

2. Mode Instruction

Page 33: Interfacing Peripheral ICs and their Chapter 7 · Priority Resolver mode set register 16-bit ... Programming the 8257 Mode and sending commands to 8257 A3 = 0 for selecting a channel’s

Ch07L3 -"Microcontrollers.........", Raj Kamal, Pearson Education, 2005

ch3Auto-reload

ch2 ch1 ch0

Channel Select

disableenable

Rotating priority Extended Write

after TC

enable

disable

TC counter

disableenable

..Mode Select Register

enable

disable

Page 34: Interfacing Peripheral ICs and their Chapter 7 · Priority Resolver mode set register 16-bit ... Programming the 8257 Mode and sending commands to 8257 A3 = 0 for selecting a channel’s

Ch07L3 -"Microcontrollers.........", Raj Kamal, Pearson Education, 2005

Status Byte (A3A2A1A0= 0)

When CS = 0, IOWR = 1, and IORD = 0 then 8051 reads status byte

Page 35: Interfacing Peripheral ICs and their Chapter 7 · Priority Resolver mode set register 16-bit ... Programming the 8257 Mode and sending commands to 8257 A3 = 0 for selecting a channel’s

Ch07L3 -"Microcontrollers.........", Raj Kamal, Pearson Education, 2005

Status flags update flag

b1 Rx-RDY

b1 ch1b3 ch3

b0 Ch0

b2 ch2

..Status Register

Page 36: Interfacing Peripheral ICs and their Chapter 7 · Priority Resolver mode set register 16-bit ... Programming the 8257 Mode and sending commands to 8257 A3 = 0 for selecting a channel’s

Ch07L3 -"Microcontrollers.........", Raj Kamal, Pearson Education, 2005

b3 =1 ch3

b4 update flag Auto-reload

b2 =1ch2

b1 =1 ch1

b0 =1 ch0

TC pin activated on TC

= 1 after a reload do not write

register TC and MAR

when 1 Remains 1 till

status register read

b7, b6, b5 = 000

..Status Register

Page 37: Interfacing Peripheral ICs and their Chapter 7 · Priority Resolver mode set register 16-bit ... Programming the 8257 Mode and sending commands to 8257 A3 = 0 for selecting a channel’s

Ch07L3 -"Microcontrollers.........", Raj Kamal, Pearson Education, 2005

Figure 7.13 - Interfacing circuit

Also refer Table 7.13for meaning of the programmed bits and status bits

Page 38: Interfacing Peripheral ICs and their Chapter 7 · Priority Resolver mode set register 16-bit ... Programming the 8257 Mode and sending commands to 8257 A3 = 0 for selecting a channel’s

Ch07L3 -"Microcontrollers.........", Raj Kamal, Pearson Education, 2005

Summary

Page 39: Interfacing Peripheral ICs and their Chapter 7 · Priority Resolver mode set register 16-bit ... Programming the 8257 Mode and sending commands to 8257 A3 = 0 for selecting a channel’s

Ch07L3 -"Microcontrollers.........", Raj Kamal, Pearson Education, 2005

Three Transaction Methods• Programmed IOs (like 8255 port used

without handshake and Intr signals)• Interrupt Driven IOs (like 8255 port

used without handshake and Intr signals)

• DMA Transactions using a DMAC

Page 40: Interfacing Peripheral ICs and their Chapter 7 · Priority Resolver mode set register 16-bit ... Programming the 8257 Mode and sending commands to 8257 A3 = 0 for selecting a channel’s

Ch07L3 -"Microcontrollers.........", Raj Kamal, Pearson Education, 2005

DMA Transaction Method• Many direct transactions between

RAM and IO devices programmed • Processor Interrupt only after a block

transferred or last byte transferred• Multi channel DMA and auto reload

features in8257

Page 41: Interfacing Peripheral ICs and their Chapter 7 · Priority Resolver mode set register 16-bit ... Programming the 8257 Mode and sending commands to 8257 A3 = 0 for selecting a channel’s

Ch07L3 -"Microcontrollers.........", Raj Kamal, Pearson Education, 2005

End of Lesson 3

8257- DMA Controller

Page 42: Interfacing Peripheral ICs and their Chapter 7 · Priority Resolver mode set register 16-bit ... Programming the 8257 Mode and sending commands to 8257 A3 = 0 for selecting a channel’s

Ch07L3 -"Microcontrollers.........", Raj Kamal, Pearson Education, 2005

THANK YOU