Wie prüft man richtig, ob ein angesprochener Slave die vom Master
ausgehende Adressierung mit ACK oder NACK quittiert hat?
Hintergrund ist ein EEPROM, der sich vom Bus komplett trennt, wenn er
Daten empfangen hat. Eine Feste Wartezeit zwischen den Zugriffen möchte
ich vermeiden.
>Minimizing System Delays by Polling On ACK
>During the internal Write cycle, the device
> discon-nects itself from the bus, and writes a copy of the
>data from its internal latches to the memory cells.
1 | void
|
2 | eeprom_wait_for_ready (void) {
|
3 | do
|
4 | {
|
5 | /* While the bus is busy */
|
6 | while(I2C_GetFlagStatus(I2C_SELECTED, I2C_FLAG_BUSY));
|
7 |
|
8 | /* Send START condition */
|
9 | I2C_GenerateSTART(I2C_SELECTED, ENABLE);
|
10 | printf("generate start");
|
11 | /* Test on EV5 and clear it */
|
12 | while(!I2C_CheckEvent(I2C_SELECTED, I2C_EVENT_MASTER_MODE_SELECT));
|
13 |
|
14 | /* Sent slave address for write */
|
15 | I2C_Send7bitAddress(I2C_SELECTED, EEPROM_I2C_ADDR, I2C_Direction_Receiver);
|
16 | printf("send address..");
|
17 |
|
18 |
|
19 | } while(!I2C_CheckEvent(I2C_SELECTED, I2C_EVENT_MASTER_RECEIVER_MODE_SELECTED));
|
20 | }
|
Vielen Dank für jede Anregung.