[stella] AtariVox/SaveKey question
Thomas Jentzsch
tjentzsch at web.de
Tue Jun 5 13:48:32 CDT 2007
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 |
More information about the Stella
mailing list