Previous

Next

Bottom

Contents

Glossary

Index

 

Persistor CF1 User's Manual

Multiple Parallel I/O

July 1998

Revision 1.01

 Persistor Instruments Inc.
© 1998 All rights reserved.
Single Chip 3.3V/5V Tolerant Jumper Selectable Octal Input/Output

Hardware: 

This circuit makes use of one 74LPT646 to provide 8 digital inputs or outputs at 3.3 volt logic levels. The I/O function is jumper selectable between Input and Output. This means that you cannot pick the mode of operation at runtime but it provides a more versatile and reusable design than our single chip input example. These I/O lines are 5 volt tolerant and can be driven by 5 volt logic. On the underside of your prototyping board you will find a set of SOIC pads that this IC will fit into if you make sure to order the 300mil wide SOIC package. At the current time this part does not appear to be available from DigiKey, but should be available from your local Pericom Distributor. The circuit diagram follows with a brief explanation below:

 

The location and function of the jumpers should be evident from the circuit diagram. Because input ports and output ports need different functionality, there is no reasonable way to make the function of this new port software configurable. When configured to be an input, the 646 acts as a tristate buffer and when configured as an output acts as a latch. We have used /CS8 in this example but you could just as easily use /CS10. One question that may arise in your mind is, "Why D8-15 and not D0-7?" The answer to this relates to how the 68338 aligns 8 bit values internally. When you pass an 8 bit value, the 68338 always aligns it in the MSB of its internal 16 bit words. You may extrapolate this design to allow 16 inputs with only one additional part, a second 74LPT245. You would wire it in exactly the same manner but to DATA0-7 instead of DATA8-15. You would even use the same chip select. But that's another story...

Application Level Interface

First and foremost you must tell the CF1 where it can find this newly added peripheral. We have made a function called IOExpandInit () to do just this. When you call this function you will have to specify the current jumper setting and tell the function whether the I/O is jumpered for input or for output.

void IOExpandInit(bool isInput)
{
	CS8Setup(0x00100000, 0x00000001, false);
	CS8Options(isInput, (isInput ? false : true), false, 0);
}

As is probably evident, this function sets up the chip selects for the new inputs or outputs. Writing to this memory location when in input mode or reading it when in output mode will cause a bus error.

Next in line are functions that allow you to "bit bang" individual lines on your new I/O. These functions each take an I/O number which corresponds to which data line you with to set, clear or read. This number should be between 0 and 7.

bool IOExpandRead(short whichLine)
{
	return (bool)(((*(vushort *)0x00100000) >> (8 + whichLine)) & 0x0001);
}

void IOExpandPSet(short whichLine)
{
	*((vushort *)0x00100000) |= (0x0100 << whichLine);	
}

void IOExpandPClr(short whichLine)
{
	*((vushort *)0x00100000) &= ((0xFEFF << whichLine) | 0x00FF);	
}

Lastly are functions that allow you to read and write to the I/O lines using whole 8 bit unsigned characters.

void IOExpandWriteByte(uchar byteToWrite)
{
	*((vushort *)0x00100000) = byteToWrite;
}
uchar IOExpandReadByte(void)
{
	return (uchar) *((vushort *)0x00100000);
}

This should put you well on your way to understanding how to add, and interact with additional, memory-mapped, parallel I/O lines. Also, as you may recall we offer more advanced application notes for adding even more I/O lines.

Back to Parallel I/O Expansion Application Note

Previous

Next

Top

Contents

Glossary

Index

Tel: 508-759-6434

Fax: 508-759-6436

Copyright (C) 1998 Persistor Instruments Inc. - All Rights Reserved