|
|
|
|
|
|
|
|
|
|
|
|
|
Take as a simple idea, that of picking up a message from a post box and transferring the message content to another. Whilst this sounds an easy task, it is ideally suited for our programming example as it can be used to identify several essential microprocessor �states�. |
|
|
|
|
|
1 |
Pick up the list of instructions. |
In programming, this is the hardware RESET. The micro turns to page ONE (the starting address) in the READ ONLY MEMORY (ROM) |
2 |
Instruction one says go to the letter box with the 6 on it, make a perfect COPY of what�s inside and put it in your pocket. |
In a program this would be an I/O (input / output) command. Go and READ in a value from a specific ADDRESS and place it in a REGISTER |
3 |
Instruction two says put a COPY of what is in your pocket into the letter box with the 9 on it |
Another I/O instruction. But this time it tells the micro to COPY what it happens to have in it�s register into a different ADDRESS |
4 |
Instruction three says stand still and stop reading the instructions! |
This is the equivalent of a HALT instruction. Not one of the more commonly used ones, but there to be obeyed all the same. |
|
|
|
|
|
More Detail? OK The HARDWARE RESET is usually actioned by taking one of the processors pins either high or low for a minimum number of clock cycles. Once the line is restored to it�s previous level, all of the programming registers will be cleared, counters restored etc. and the program counter (the page �one� in the book, set to the first address. The first instruction - the I/O read will generally be two bytes long minimum. One to tell the processor to DO the instruction, and the second being where to DO it - i.e. the address. The HARDWARE MUST be electrically configured such that the processor will FIND the value at that specific address. The second instruction says put what�s in the register into a second I/O address - once again to be set up in HARDWARE where the processor expects it to be. If it is NOT set up correctly, the processor will still send it out, but it will of course disappear into the ether. |
|
|
|
|
|
|
|
Both the I and the O parts are accessed by the micro in an almost identical manner. With some processors, the I/O is addressed by the same decoder as the memory - i.e. all DATA TRANSFERS take place at specifically chosen addresses. With some other families, special I/O pins are available from the micro to select the I/O devices with a modified access cycle . |
|
|
|
|
|
|
|
|
|
INTERFACING I/O DEVICES I/O devices are accessed in much the same way as the memory, though they sometimes need addressing by an external addressing device or decoder. The most basic devices being simply latches or even buffers, enabled by a decoder or I/O line. In the case of the TIL311 display device shown above, the package incorporates not only the LED segments, but also the binary to segment decoder AND a data latch! You can see the actual chip itself in the bottom half of the device. All in all, a very easy and convenient display to use, as all one does is connect it�s four data lines straight up to the processors data bus, and the strobe to the I/O decoder. Voila! Note that it only has four data lines, so you have to decide whether to connect to the top half of the bus or the lower half. Of course if using two TIL311�s, one could use the LOWER four bits for one display and the UPPER four bits for the other. By commoning the enable lines, one could then update them in the program simultaneously from the same byte! (assuming an 8 bit processor) Although PIO and PIA multi I/O LSI chips offer many different interfacing options, as a general rule, I tend to avoid them unless these facilities (such as interrupts) are really needed, as it is usually simpler to use either two or three tri-state latches or buffers. The ones I most commonly use are the 74xx373 or 374 octal latches, or the 74xx240 241 244 series octal buffers. Where bi-directional tri-state buffers are needed - such as that required with a multiplexed data / address bus, I generally opt for the 74xx245. Where space is at a premium and if only 4 bits are needed, the 74xx125 is a viable alternative tri-state device in a 14 pin pack. (The others all mentioned above are 20 pin.) |
|
|
|
|
|
|
INTERFACING MEMORY DEVICES Memory is something that all micro�s need to interface to. It will be noticed that there is almost a �standard� for the pin layout used by most of these - which can be very useful at times. Have a look at a few of the pinouts in the Data Sheets section to see for yourself. Memory is connected by it�s ADDRESS and DATA lines to the processor and accessed via it�s chip select and memory read / write lines. This is where the chips vary a little with capacities and type. Almost ALL will be accessed by taking their enable lines LOW. Read / Write lines invariably need the line taken low to WRITE. A memory device may have more select lines than you need - i.e. /CE1 (chip enable 1) /CE2 (chip enable 2) and /OE (output enable) etc. You only have to use those that you need. Simply hard-wire-enable the ones that you don�t need, remembering that an output enable (for example) can�t enable anything if the chip itself is not enabled with the /CE lines. |
|
|
|
|
|
|
TO BUFFER OR NOT TO BUFFER? Although it is necessary to buffer data and address lines if the number of devices on the bus exceeeds the drive capability of the microprocessor, I�ve never found this necessary with any of my home micro projects. |
|
|
|
|