C
communications. This is accomplished by
setting the
output data for these two I/O pins low and using the directions setting of the
pins to
determine the
logic level of the signal lines. Whenever a logic high is required, the
direction bit
for the
corresponding pin is set to configure that pin as an input. The pullup resistor
on the signal
line then pulls
it to a logic high state. If a logic low is required, the direction bit is set
to switch the
pin to an
output. Since the data for the pins was previously set low, the signal line will
be pulled
low by the pin
being switched to an output.
The MSP430 initiates a write to a random byte of the EEPROM
memory, by first sending a start
condition. Then
the control byte is sent. The control byte consists of the device code for
the
specific device
that is being addressed, the address of the memory block being accessed, and
a
bit that
indicates whether a read or write operation is being performed (see Figure 1).
The
EEPROM then
acknowledges receipt of the byte. The MSP430
then sends the specific memory
address of the
byte being written to. The EEPROM acknowledges again. The MSP430 then
sends the data
to be written into the memory byte. After the EEPROM acknowledges the
data,
the MSP430 sends a stop condition.
The reading of
random bytes of the EEPROM memory is somewhat different than writing
to
them. The main
difference is that the control byte is sent twice, once before the MSP430 sends
the address byte
and a second time before the EEPROM returns the requested data byte.
The
read/write bit
of the control word is also set to a logic high to indicate a read
operation.
The associated
software was written specifically to address the 512 bytes of memory in
a
24LC04 EEPROM,
but smaller memories would also work since the address bits in the
control
byte would be
ignored. Larger memories that utilize more of the address bits in the control
byte
could also be
supported if the software were modified to set the address bits as
required.
The user
interface is accomplished by communicating with a terminal program running on a
PC.
Memory and data
bytes are exchanged between the MSP430 and PC
in the form of ASCII
characters. The
terminal program runs at 9600 baud using an 8N1
protocol.