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
Message
Re: Writing 8 bits on the IO port
2005-04-19 by dibosco
Attachments
- No local attachments were found for this message.