18.11.2014 Views

The Microcontroller Idea Book - Jan Axelson's Lakeview Research

The Microcontroller Idea Book - Jan Axelson's Lakeview Research

The Microcontroller Idea Book - Jan Axelson's Lakeview Research

SHOW MORE
SHOW LESS

You also want an ePaper? Increase the reach of your titles

YUMPU automatically turns print PDFs into web optimized ePapers that Google loves.

If you wish, you can wire U14’s inputs and U12’s outputs to headers for easy access when<br />

you want to connect clip-on jumpers, probe leads, or ribbon cables to the inputs and outputs.<br />

Basic Tests<br />

What can you do with these new inputs and outputs? First, some simple tests. You read and<br />

write to the ports exactly as you read and write to external memory. This BASIC-52 statement<br />

will display the value of the byte at U12’s inputs:<br />

PRINT XBY(0E000h)<br />

Or, you may prefer a hexadecimal display:<br />

PH0. XBY(0E000h)<br />

To verify that you’re reading all bits correctly, jumper each input in turn to ground and +5V<br />

and read the results. Open inputs are undefined and may read as high or low.<br />

To test U14’s outputs, use this BASIC-52 statement:<br />

XBY(0E400h)=xx<br />

where xx is the value you want to write to the chip. To set all bits, write 255 or 0FFh. To<br />

clear them, write 0. To verify that all bits are responding, connect a logic probe, voltmeter,<br />

or oscilloscope to each of the outputs of U14 in turn and verify that the bits respond correctly<br />

to your commands.<br />

Input Examples<br />

Figure 6-3 shows some inputs that you can interface to U12.<br />

Inputs and Outputs<br />

(A) TTL or CMOS logic outputs powered at 5 volts can directly drive U12’s inputs.<br />

(B) To translate lower voltages to 5-volt logic, use a 74HCT03 or similar open-drain NAND<br />

gate with a pullup resistor to 5 volts.<br />

(C) To translate higher voltages to 5-volt logic, use a 74HC4050 buffer or 74HC4049<br />

inverter, powered at 5 volts. <strong>The</strong>se chips can safely accept inputs up to 15 volts.<br />

(D) You can also detect the state (open or closed) of a toggle or slide switch at a port pin.<br />

(E) An optocoupler is another way to interface different voltage levels, and it also electrically<br />

isolates the input from the microcontroller circuit.<br />

<strong>The</strong> <strong>Microcontroller</strong> <strong>Idea</strong> <strong>Book</strong> 93

Hooray! Your file is uploaded and ready to be published.

Saved successfully!

Ooh no, something went wrong!