----- Original Message -----
From: Aalt Lokhorst
To: lpc2000@yahoogroups.com
Sent: Tuesday, April 19, 2005 4:38 AM
Subject: Re: [lpc2000] Re: Writing 8 bits on the IO port
Hello Kimi and Rob,
Rob his solution reads the current port status. In most situations this
is no problem. But it is a read/modify write situation and I don't know
if you always want that. You can also use something like this (not
tested but I think it is clear what I mean):
IO0SET = ( Data<<14) & 0x3FC0;
IO0CLR = (~Data<<14) & 0x3FC0;
It changes the data bus in two steps so there will be intermediate
values on the bus. This is not a problem if you use separate control
lines to control when the data is valid. Don't forget to set the
direction of the pins according to the read or write situation and avoid
collisions as a result of two devices driving the bus at the same time.
Best regards,
--
==============================
Aalt Lokhorst
Schut Geometrische Meettechniek bv
Duinkerkenstraat 21
9723 BN Groningen
P.O. Box 5225
9700 GE Groningen
The Netherlands
Tel: +31-50-5877877
Fax: +31-50-5877899
E-mail: Lokhorst@...
==============================
dibosco wrote:
>
> I've done an almost identical thing and just got my char value to
> write, chifted into its correct position in a temporary value in a
> long. Then read what's currently on the output port into another
> temporary long, ANDed out the relevant eight bits, then ORed into this
> the new bits which are in the correct positiion in the temporary long.
> This value is then written to the output port.
>
> Not sure that reads very well. Some code:
>
> // put char to write in temp and shift it to correct position
> Temp1 = NewVal << 14;
> // Get current output value of PORT0
> Temp2 = IO0PIN;
> // AND out P0.14-21
> Temp2 &= ~0x3FC000;
> //OR in what you *do* want to write.
> Temp2 |= Temp1;
> // Then write to the port
> IO0PIN = Temp1;
>
> Check the syntax of that last line's right!
>
> And you've written the value to the port. :-)
>
> Cheers,
>
> Rob
>
> --- In lpc2000@yahoogroups.com, "acetoel" <acetoel@y...> wrote:
> >
> > Hello,
> >
> > I making a little protocol to interfase between a LPC2106 and an Atmel
> > 8bits MCU. My idea is to use an 8bit data bus (P0.14 to P0.21) for
> > sending and receiving bytes, and then a few control lines (Busy/Ready,
> > Clock, Enable, Command/Data).
> > How can I write a byte variable (char) to that 8bit port? and how can
> > I read that data port, and save it on a variable? being P0.14 is the
> > Least Significative bit.
> >
> > Thanks
> > Kimi
>
>
>
>
> ------------------------------------------------------------------------
> *Yahoo! Groups Links*
>
> * To visit your group on the web, go to:
> http://groups.yahoo.com/group/lpc2000/
>
> * To unsubscribe from this group, send an email to:
> lpc2000-unsubscribe@yahoogroups.com
> <mailto:lpc2000-unsubscribe@yahoogroups.com?subject=Unsubscribe>
>
> * Your use of Yahoo! Groups is subject to the Yahoo! Terms of
> Service <http://docs.yahoo.com/info/terms/>.
>
>
------------------------------------------------------------------------------
Yahoo! Groups Links
a.. To visit your group on the web, go to:
http://groups.yahoo.com/group/lpc2000/
b.. To unsubscribe from this group, send an email to:
lpc2000-unsubscribe@yahoogroups.com
c.. Your use of Yahoo! Groups is subject to the Yahoo! Terms of Service.
[Non-text portions of this message have been removed]