[stella] AtariVox/SaveKey question
bob.montgomery at thomson.com
bob.montgomery at thomson.com
Tue Jun 5 13:59:08 CDT 2007
Hi Thomas,
So the acknowledge bit is only necessary when reading, and I just make
sure the overflow-flag is clear when I call i2c_rxbyte.
Correct?
Thanks,
-Bob
-----Original Message-----
From: stella-bounces at atari2600.org [mailto:stella-bounces at atari2600.org]
On Behalf Of Thomas Jentzsch
Sent: Tuesday, June 05, 2007 11:49 AM
To: Atari 2600 programming list
Subject: Re: [stella] AtariVox/SaveKey question
Bob Montgomery wrote:
> I can't quite figure out how the overflow-flag should be set -
> can you help me out? When do I need an acknowledge bit? Is it
> ever necessary?
Here is what Alex wrote me (I had the very same questions :-):
"Normally, after reading a byte, we transmit a 0 bit for acknowledge.
This
tells the EEPROM to continue transmitting data on future pulses of SCL.
However, once we have read all the bytes we want, a 1 is transmitted for
"not-acknowledge" instead, which stops the chip from sending any more
data.
(It's not possible to issue a "stop" signal while the EEPROM is trying
to
transmit. The I2C protocol is a little clumsy.)
When writing the driver code, I found it simpler to put the ACK part at
the
start of i2c_rxbyte (to acknowledge a *previous* byte read). So we only
transmit the 0 when we *know* that more data is going to be read. (The
V
flag indicates whether a byte has been read previously - so we don't
transmit ACK before reading the first byte.) The Not-ACK is then done
in
i2c_stopread.
If you destroy the V flag during EEPROM reads (which I imagine will be
the
case if you're spreading reads across frames), and if you always read
the
same number of bytes, it might be simpler to have 2 different "rxbyte"
routines. A normal "rxbyte" which always transmits an ACK (0) at the
end,
and a "rxlastbyte" which transmits a NACK (1) which is only used when
reading the last byte of data."
Hope that helps.
Have fun!
Thomas
_______________________________________________________
Thomas Jentzsch | *** Every bit is sacred ! ***
tjentzsch at web dot de |
_______________________________________________
Stella mailing list
Stella at atari2600.org
http://atari2600.org/mailman/listinfo/stella
More information about the Stella
mailing list