Reply by jetq88 March 9, 20072007-03-09
On Mar 9, 11:58 am, stephen...@mpeforth.com (Stephen Pelc) wrote:
> On 9 Mar 2007 09:34:27 -0800, "jetq88" <jetq5...@gmail.com> wrote: > > >thanks for your reply, I think my question is kind of confusing, I > >meant to ask what will happen if two output pins connected to one > >line, one is put the line to high, the other is put the line to low > >since LPC21xx GPIO pins have no tri-state. > > The trick for open drain is to set the ouput permanently to a '0', > using IOCLR, and then use the IODIR direction register to set the > output state. When it's an input, the pull-up resistor will pull > the pin high. When it's an output, the preset 0 value takes it > low. > > Stephen > > -- > Stephen Pelc, stephen...@mpeforth.com > MicroProcessor Engineering Ltd - More Real, Less Time > 133 Hill Lane, Southampton SO15 5AF, England > tel: +44 (0)23 8063 1441, fax: +44 (0)23 8033 9691 > web:http://www.mpeforth.com- free VFX Forth downloads
very valuable information, great discussion on this subject , guys, thanks a lot =========== regards jet
Reply by CBFalconer March 9, 20072007-03-09
Stephen Pelc wrote:
> "jetq88" <jetq5188@gmail.com> wrote: > >> thanks for your reply, I think my question is kind of confusing, >> I meant to ask what will happen if two output pins connected to >> one line, one is put the line to high, the other is put the line >> to low since LPC21xx GPIO pins have no tri-state. > > The trick for open drain is to set the ouput permanently to a '0', > using IOCLR, and then use the IODIR direction register to set the > output state. When it's an input, the pull-up resistor will pull > the pin high. When it's an output, the preset 0 value takes it low.
I assume that device has normal pull up/down capabilities in the output mode, otherwise if it is a normal open drain output it will be much simpler, and the code clearer, to simply control it via the normal output port. BTW, to us old fogies, all that is known as 'wired or' configuration, for negative logic. It's the thing the original IBM PC designers didn't know when they designed the interrupt line configuration. -- Some informative links: <http://www.catb.org/~esr/faqs/smart-questions.html> <http://www.caliburn.nl/topposting.html> <http://www.netmeister.org/news/learn2quote.html> <http://cfaj.freeshell.org/google/> (taming google) <http://members.fortunecity.com/nnqweb/> (newusers) -- Posted via a free Usenet account from http://www.teranews.com
Reply by CBFalconer March 9, 20072007-03-09
jetq88 wrote:
> > sorry for the figure. > > --------------------- | ---------------------- > | | | | | > | |----------| | | > | MCU | | | Other | > | | |-------------| | > | | | | | > | | | | | > --------------------- | ---------------------- > | > line(or bus)
Still fouled up, but not quite as badly. Ensure you always use a fixed width font for Usenet, especially if you want to use any Ascii art. Some of the following links may help. -- Some informative links: <http://www.catb.org/~esr/faqs/smart-questions.html> <http://www.caliburn.nl/topposting.html> <http://www.netmeister.org/news/learn2quote.html> <http://cfaj.freeshell.org/google/> (taming google) <http://members.fortunecity.com/nnqweb/> (newusers) -- Posted via a free Usenet account from http://www.teranews.com
Reply by Robert Adsett March 9, 20072007-03-09
On Mar 9, 1:13 pm, "Robert Adsett" <s...@aeolusdevelopment.com> wrote:
> On Mar 9, 12:34 pm, "jetq88" <jetq5...@gmail.com> wrote: > > > hi, Joe, > > > thanks for your reply, I think my question is kind of confusing, I > > meant to ask what will happen if two output pins connected to one > > line, one is put the line to high, the other is put the line to low > > since LPC21xx GPIO pins have no tri-state. > > Um, when the pin is set to input it is tri-stated, it's not driving > the output. It sounds more like you are looking for a Quasi bi- > directional pin or possibly an open-collector.
And I forgot to mention that if you don't need IIC these chips already have outputs that do that. Robert
Reply by Peter Dickerson March 9, 20072007-03-09
"Stephen Pelc" <stephenXXX@mpeforth.com> wrote in message 
news:45f19f54.3828509937@192.168.0.50...
> On 9 Mar 2007 09:34:27 -0800, "jetq88" <jetq5188@gmail.com> wrote: > >>thanks for your reply, I think my question is kind of confusing, I >>meant to ask what will happen if two output pins connected to one >>line, one is put the line to high, the other is put the line to low >>since LPC21xx GPIO pins have no tri-state. > > The trick for open drain is to set the ouput permanently to a '0', > using IOCLR, and then use the IODIR direction register to set the > output state. When it's an input, the pull-up resistor will pull > the pin high. When it's an output, the preset 0 value takes it > low.
I have used this approac many a time on various micros but found recently that it doesn't work for Sharp ARM LH754xx parts :-( What happens instead is that when the port is input the output register follows the input. So if you have a pull-up then switch from input to output will always drive high (unless somthing else was holding it low). Hopefully the LPC parts don't have this problem... Peter
Reply by Robert Adsett March 9, 20072007-03-09
On Mar 9, 12:34 pm, "jetq88" <jetq5...@gmail.com> wrote:
> hi, Joe, > > thanks for your reply, I think my question is kind of confusing, I > meant to ask what will happen if two output pins connected to one > line, one is put the line to high, the other is put the line to low > since LPC21xx GPIO pins have no tri-state.
Um, when the pin is set to input it is tri-stated, it's not driving the output. It sounds more like you are looking for a Quasi bi- directional pin or possibly an open-collector. As to what happens when two pins with different outputs are connected together, I doubt it's predictable. In the worst case it will be destructive if the drivers are beefy enough to overheat themselves. Robert
Reply by Stephen Pelc March 9, 20072007-03-09
On 9 Mar 2007 09:34:27 -0800, "jetq88" <jetq5188@gmail.com> wrote:

>thanks for your reply, I think my question is kind of confusing, I >meant to ask what will happen if two output pins connected to one >line, one is put the line to high, the other is put the line to low >since LPC21xx GPIO pins have no tri-state.
The trick for open drain is to set the ouput permanently to a '0', using IOCLR, and then use the IODIR direction register to set the output state. When it's an input, the pull-up resistor will pull the pin high. When it's an output, the preset 0 value takes it low. Stephen -- Stephen Pelc, stephenXXX@mpeforth.com MicroProcessor Engineering Ltd - More Real, Less Time 133 Hill Lane, Southampton SO15 5AF, England tel: +44 (0)23 8063 1441, fax: +44 (0)23 8033 9691 web: http://www.mpeforth.com - free VFX Forth downloads
Reply by Mike Silva March 9, 20072007-03-09
On Mar 9, 12:34 pm, "jetq88" <jetq5...@gmail.com> wrote:
> after read LPC21xx datasheet, i wonder if LPC accomplish this by > change pin direction to input, it didn't state how to put pin in tri- > stae.
You can always accomplish this by writing a '0' to the pin, putting a pull-up on the pin and using the pin's direction bit to either (a) write a '0' (by setting the pin to output) or (b) writing a '1' / freeing the line (by setting the pin to input). I have used this approach successfully, but there are 3 issues I can think of with it. First, pullups are slow, so your 0-to-1 transition won't be as fast as your 1-to-0 transition. I think the 8051 has a brief active pullup on a 0-to-1 transition to speed things up. Second, you'll have to check how fast the pin actually changes after you write to the direction bit and make sure your system can handle any delay there. Third, you may very well find that you need to write a '1' to put a '0' on the pin, and vice versa. If all of the drivers and receivers on the line can deal with it, you could use a pull-down rather than a pull-up and avoid the bit inversion issue (not that it's usually a big deal).
Reply by Arlet March 9, 20072007-03-09
On Mar 9, 6:34 pm, "jetq88" <jetq5...@gmail.com> wrote:

> thanks for your reply, I think my question is kind of confusing, I > meant to ask what will happen if two output pins connected to one > line, one is put the line to high, the other is put the line to low > since LPC21xx GPIO pins have no tri-state.
That would be bad. Excessive current will flow from the 'high' pin to the 'low' pin, possibly causing damage the parts.
> in 8051 or other MCU, if two output pins are connected to one line, > they can be configed as open-drain, then this line can be controlled > by one output pin at a time, for example, if MCU want to release line, > let other to set this line high or low, it put its output pin in tri- > state, then this line can be put high or low by other.
On the LPC21xx, you would have to switch the pin to an input. This will make it high-impedance, and it can be connected to an output pin without a problem. If you just want to toggle between a strong low, and a weak high, you can connect a pull-up resistor to the pin and program a fixed '0' output value. Then you use the direction bit to switch between 0 (output) and weak 1 (input).
Reply by jetq88 March 9, 20072007-03-09
sorry for the figure.

---------------------           |            ----------------------
|                    |          |             |                    |
|                    |----------|             |                    |
|   MCU          |          |             |    Other        |
|                    |          |-------------|                    |
|                    |          |             |                    |
|                    |          |             |                    |
 ---------------------          |             ----------------------
                                |
                           line(or bus)

On Mar 9, 11:34 am, "jetq88" <jetq5...@gmail.com> wrote:
> hi, Joe, > > thanks for your reply, I think my question is kind of confusing, I > meant to ask what will happen if two output pins connected to one > line, one is put the line to high, the other is put the line to low > since LPC21xx GPIO pins have no tri-state. > > in 8051 or other MCU, if two output pins are connected to one line, > they can be configed as open-drain, then this line can be controlled > by one output pin at a time, for example, if MCU want to release line, > let other to set this line high or low, it put its output pin in tri- > state, then this line can be put high or low by other. > > --------------------- | > ---------------------- > | | | > | | > | |----------| > | | > | MCU | | | > Other | > | | > |-------------| | > | | | > | | > | | | > | | > --------------------- | > ---------------------- > | > line(or bus) > > after read LPC21xx datasheet, i wonder if LPC accomplish this by > change pin direction to input, it didn't state how to put pin in tri- > stae. > > On Mar 9, 8:36 am, "Joe G \(Home\)" <j...@optusnet.com.au> wrote: > > > > > Standard "classic" 8051 has quasi-bidirectional ports. > > > The LPC21xx ports can be configured as input or output. > > > From the LPC2138 Data sheets > > 6.10 General purpose parallel I/O > > > Device pins that are not connected to a specific peripheral function are > > controlled by the > > > GPIO registers. Pins may be dynamically configured as inputs or outputs. > > Separate > > > registers allow setting or clearing any number of outputs simultaneously. > > The value of the > > > output register may be read back, as well as the current state of the port > > pins. > > > 6.10.1 Features > > > . Direction control of individual bits. > > > . Separate control of output set and clear. > > > . All I/O default to inputs after reset. > > > There is a reasonable Yahoo forum on the LPC2000 devices. > > > "jetq88" <jetq5...@gmail.com> wrote in message > > >news:1173391120.788641.280720@h3g2000cwc.googlegroups.com... > > > > in 8051, GPIO pins can be configed as both input and output buy > > > putting pins in high-impedance state,then this pin can be read and > > > write as input or output(like bus), in LPC21xx, a pin is either input > > > or output, there is no high-impedance state, can I make one GPIO pin > > > as input/output in LPC21xx? > > > > thanks > > > jet- Hide quoted text - > > > - Show quoted text -- Hide quoted text - > > - Show quoted text -