external memory & i/o
DESCRIPTION
External Memory & I/O. External communications Designing an external 3 Byte Interface. You already have an external 1 Byte memory. * = INVERTED. Output Enable * (Read Data). Byte coming in (PORTA). Byte Stored (PORTE). CP (Write Data). Control lines (PORTD). Computer Bus. - PowerPoint PPT PresentationTRANSCRIPT
![Page 1: External Memory & I/O](https://reader030.vdocument.in/reader030/viewer/2022012822/568135aa550346895d9d1a2a/html5/thumbnails/1.jpg)
1
E X T E R N A L C O M M U N I C AT I O N S
D E S I G N I N G A N E X T E R N A L 3 B Y T E I N T E R FA C E
Mark Neil - Microprocessor Course
External Memory & I/O
![Page 2: External Memory & I/O](https://reader030.vdocument.in/reader030/viewer/2022012822/568135aa550346895d9d1a2a/html5/thumbnails/2.jpg)
Mark Neil - Microprocessor Course
2
You already have an external 1 Byte memory
CP (Write Data)
Byte coming in
(PORTA)
Byte Stored(PORTE)
Output Enable* (Read Data)
* = INVERTED
Control lines(PORTD)
![Page 3: External Memory & I/O](https://reader030.vdocument.in/reader030/viewer/2022012822/568135aa550346895d9d1a2a/html5/thumbnails/3.jpg)
3
Computer Bus
Mark Neil - Microprocessor Course
The processor within a computer communicates with the other computer modules via a device called: Bus.
Many different Bus architectures exist in the market such as PCI; cPCI; VME….
All bus architectures include a control bus, a data bus and an address bus.
![Page 4: External Memory & I/O](https://reader030.vdocument.in/reader030/viewer/2022012822/568135aa550346895d9d1a2a/html5/thumbnails/4.jpg)
4
The BUS of a computer:
Mark Neil - Microprocessor Course
Address Lines
Data Lines
Control Lines
Bus Master(CPU/Controller)
Bus Slave(e.g. Memory)
![Page 5: External Memory & I/O](https://reader030.vdocument.in/reader030/viewer/2022012822/568135aa550346895d9d1a2a/html5/thumbnails/5.jpg)
5
Typical Write Sequence
Mark Neil - Microprocessor Course
The bus master places the address of the memory where the datum is to be written on the bus and validates it using the control lines.
The master signals using the control lines that this is a write sequence.
The master places the datum to be written onto the bus and validates it using the control lines.
Each slave compares the address on the bus with its own address. If the write refers to it, it takes the data and signals (acknowledges) using the control lines that this has been done.
![Page 6: External Memory & I/O](https://reader030.vdocument.in/reader030/viewer/2022012822/568135aa550346895d9d1a2a/html5/thumbnails/6.jpg)
6
Typical Read Sequence
Mark Neil - Microprocessor Course
The master places the address of the memory from where the datum is to be read on the bus and validates it using the control lines.
The master signals using the control lines that this is a read sequence.
The master signals that it is ready to accept the datum using the control lines.
The slave compares the address on the bus with its own address. If the read refers to it, it places the datum on the bus and validates it using the control lines (acknowledges the data). At the end the Master latches the datum.
![Page 7: External Memory & I/O](https://reader030.vdocument.in/reader030/viewer/2022012822/568135aa550346895d9d1a2a/html5/thumbnails/7.jpg)
7
Parallel Transfer
Mark Neil - Microprocessor Course
In a bus all bits of a byte or word are transferred simultaneously.
If we have a byte wide bus and a transfer frequency of 1MHz then we have a bus speed of 1Mbytes/sec
Hence, this is called Parallel Data Transfer (opposed to Serial Data Transfer that we will learn next)
![Page 8: External Memory & I/O](https://reader030.vdocument.in/reader030/viewer/2022012822/568135aa550346895d9d1a2a/html5/thumbnails/8.jpg)
8
Interface to External SRAM
Mark Neil - Microprocessor Course
Bus is implemented by using two of the ports!
![Page 9: External Memory & I/O](https://reader030.vdocument.in/reader030/viewer/2022012822/568135aa550346895d9d1a2a/html5/thumbnails/9.jpg)
9
Electronics Exercise
Mark Neil - Microprocessor Course
We will now make a 3 Byte interface that you can use for external read and write from/to the ATmega128 board.
This is a challenging exercise and will take some time to construct and test
![Page 10: External Memory & I/O](https://reader030.vdocument.in/reader030/viewer/2022012822/568135aa550346895d9d1a2a/html5/thumbnails/10.jpg)
10
High Level Design :3 Byte Memory
Mark Neil - Microprocessor Course
We want to construct :
ATmega103Board
8-Bits of data_in
8-Bits of data_out
PORTA (Output)
PORTE (Input)
PORTD (Output Only) AS, READWRITE, A0,A1
Control andAddress
bus1-Byte
Memory
1-ByteMemory
Data Bus Out
Data Bus In
1-ByteMemory
![Page 11: External Memory & I/O](https://reader030.vdocument.in/reader030/viewer/2022012822/568135aa550346895d9d1a2a/html5/thumbnails/11.jpg)
11
The data sheet for the 74F138
Mark Neil - Microprocessor Course
You will need to select which memory chip to write to using a binary address
You will convert the 2 bits of “Address” into 3 lines which can be used to control the Enable lines for the three memory chips
To do this use an address decoder
The 74F138 converts a 3 bit address into 8 control output lines When a given 3 bit number is
written on the Address lines one of the 8 output lines is set high
![Page 12: External Memory & I/O](https://reader030.vdocument.in/reader030/viewer/2022012822/568135aa550346895d9d1a2a/html5/thumbnails/12.jpg)
12
The 74F138 truth table
Mark Neil - Microprocessor Course
![Page 13: External Memory & I/O](https://reader030.vdocument.in/reader030/viewer/2022012822/568135aa550346895d9d1a2a/html5/thumbnails/13.jpg)
13
Memory Design
Data to write to the memory is placed on PORTA and this is wired to the memory Data Bus
The data is read from the memories into PORTE from the output Data Bus
The control lines for all this are sent on PORTD
Mark Neil - Microprocessor Course
PORTEPORTA
![Page 14: External Memory & I/O](https://reader030.vdocument.in/reader030/viewer/2022012822/568135aa550346895d9d1a2a/html5/thumbnails/14.jpg)
14
Control BusWe need to set four signals to control the memories
A0:A1 – The Address Bits. These are used to define which memory chip will be addressed (00,01,10)
AS* – The address strobe to select the memory
R*/W to Read/Write the selected memory\
We will use bits on PORTD to control these signals – you chose which bits are attached to which control line
Mark Neil - Microprocessor Course
![Page 15: External Memory & I/O](https://reader030.vdocument.in/reader030/viewer/2022012822/568135aa550346895d9d1a2a/html5/thumbnails/15.jpg)
15Mark Neil - Microprocessor Course
Control Signals
AS,A1,A0R/W
On PORTD
Input Data (D0-D7) Bus – from PORTA
Output Data Bus (O0-O7) on PORTE
Basic Circuit
![Page 16: External Memory & I/O](https://reader030.vdocument.in/reader030/viewer/2022012822/568135aa550346895d9d1a2a/html5/thumbnails/16.jpg)
16
Logic Gates
Mark Neil - Microprocessor Course
You will also use some basic logic gates in your circuit to build the control bus 74HC04 Hex Not 74HC08 Quad And 74HC32 Quad OR
![Page 17: External Memory & I/O](https://reader030.vdocument.in/reader030/viewer/2022012822/568135aa550346895d9d1a2a/html5/thumbnails/17.jpg)
17
Logic Table for Control BusTo read a memory,
o Address it on A0/A1
o set AS* to 0
o set R*W to 0
To Write a memory,
o Address it on A0/A1
o Set AS* to 0
o Change R*W from 0 to 1
Make sure you understand the Logic table and how it is implemented using the logic gates
AS*
R*W
A1
A0
O0*
O1*
R0*
W0
R1*
W1
Function
0 0 0 0 0 1 0 0 1 0 Read Memory 0 (OE*)
0 1 0 0 0 1 1 1 1 0 Write Memory 0 (CP)
1 0 0 0 1 1 1 0 1 0
1 1 0 0 1 1 1 0 1 0
0 0 0 1 1 0 1 0 0 0 Read Memory 1 (OE*)
0 1 0 1 1 0 1 0 1 1 Write Memory 1 (CP)
1 0 0 1 1 1 1 0 1 0
1 1 0 1 1 1 1 0 1 0
Mark Neil - Microprocessor Course
Exercise: Fill in the Table for Read2*/Write2
![Page 18: External Memory & I/O](https://reader030.vdocument.in/reader030/viewer/2022012822/568135aa550346895d9d1a2a/html5/thumbnails/18.jpg)
18
Sequence Diagram:
Mark Neil - Microprocessor Course
Unneccessary - need another D-Flip-Flop to remove
Unneccessary - need another D-Flip-Flop to remove
![Page 19: External Memory & I/O](https://reader030.vdocument.in/reader030/viewer/2022012822/568135aa550346895d9d1a2a/html5/thumbnails/19.jpg)
19
The Memory Test Program
Mark Neil - Microprocessor Course
Start
Set data pattern onPORTA
Clock in memory 1
Set data pattern onPORTA
Set data pattern onPORTA
Clock in memory 2
Clock in memory 3
Enable memory 1 output
Enable memory 3 output
Enable memory 2 output
Copy PINE to PORTB LEDs
Copy PINE to PORTB LEDs
Copy PINE to PORTB LEDs
![Page 20: External Memory & I/O](https://reader030.vdocument.in/reader030/viewer/2022012822/568135aa550346895d9d1a2a/html5/thumbnails/20.jpg)
20
Task Plan:
Mark Neil - Microprocessor Course
Construct the 3 byte memory and connect it to your ATmage128 Board
Always connect to the ports through the special cable-resistor-pack units
Proceed in steps: First the Control Bus, test it and verify that it works! Next add the first memory byte and test it Add the second memory and test it Add the third memory and test it
Write programs as you go along with the aid of a top-down-modular diagram
Use a main section Use driver subroutines that read, write, and loop data through
your memory bytes.
![Page 21: External Memory & I/O](https://reader030.vdocument.in/reader030/viewer/2022012822/568135aa550346895d9d1a2a/html5/thumbnails/21.jpg)
21
Some Comments:
Mark Neil - Microprocessor Course
Make a detailed schematic of your device with all ICs (logic diagrams) and the IC pin assignments.
Make sure that you understand your design BEFORE you start building it.
Build the device in pieces which you can check using your software. Don’t build the entire design before testing. Follow the steps – don’t leap ahead and build too much
before checking that everything works at each step.Use the oscilloscope and the DVM to check what
is going on and debug your device.
![Page 22: External Memory & I/O](https://reader030.vdocument.in/reader030/viewer/2022012822/568135aa550346895d9d1a2a/html5/thumbnails/22.jpg)
22
How to Draw Schematics:
Mark Neil - Microprocessor Course
![Page 23: External Memory & I/O](https://reader030.vdocument.in/reader030/viewer/2022012822/568135aa550346895d9d1a2a/html5/thumbnails/23.jpg)
23
Step 1: The control bus Address lines
Mark Neil - Microprocessor Course
Start by setting the Address Strobe* high
Set the correct address on your bus.
Now lower the AS* and check that the appropriate output bits are selected for the address of each memory
![Page 24: External Memory & I/O](https://reader030.vdocument.in/reader030/viewer/2022012822/568135aa550346895d9d1a2a/html5/thumbnails/24.jpg)
24
The control bus Read/Write
Mark Neil - Microprocessor Course
Add the Read/Write control logic First build Read0*/Write0
Set AS* high and R*/W high. Set the address on your bus Lower R*W and AS*
This is a read memory setting Check that Read0*/Write0 are what
you expect Bring *R/W High for 250 nsec and
then back Low This is a write memory Use a scope to verify the timing
Complete the Read1*/Write1 and Read2*/Write2 circuits Test that they are working as expected
when you select each of the memory addresses.
you are ready to add a memory Don’t this before your control bus
works!
![Page 25: External Memory & I/O](https://reader030.vdocument.in/reader030/viewer/2022012822/568135aa550346895d9d1a2a/html5/thumbnails/25.jpg)
25
Step 3: Adding the first memory
Mark Neil - Microprocessor Course
Connect the Data Bus (D0-D7) to the 8 bits on PORTA
Connect the OE* to the Read* and CP to the Write lines of your control bus
Using your program Set AS* high and R*/W high . Set the correct address and put some
data on your bus. Lower R*/W and AS* Bring R*/W high for 250 nsec and then
back to Low Your data should now be stored in the
selected register, and visible on the outputs
Before you connect the output together use scope/LED+Resistors to check if the data are on the outputs and correct
Connect the Output Bus to the pins on PORTE
Try reading the data with the AVR
![Page 26: External Memory & I/O](https://reader030.vdocument.in/reader030/viewer/2022012822/568135aa550346895d9d1a2a/html5/thumbnails/26.jpg)
26
Step 4
Add the second Memory Chip
Verify that it is working as expected
Finally Add the third memory chip
You should now be able to write data to the memory of your choice, and verify that it is properly stored
Mark Neil - Microprocessor Course
![Page 27: External Memory & I/O](https://reader030.vdocument.in/reader030/viewer/2022012822/568135aa550346895d9d1a2a/html5/thumbnails/27.jpg)
27
Here is an example…
When you build your board Think about
Where inputs arrive
Where the outputs go
Where the memory buses will be
Where the control bus will be
What color wire you will use for what function
Mark Neil - Microprocessor Course