How I can read more than 256 bytes by I2C without repeated Start?
Suggested sequence for 300 bytes:
1. write to I2CMCNT0 = 255 + 0x100 (256 bytes + set bit 8)
2. read 255 bytes and write on-the-fly I2CMCNT0 = 44
3. read 45 bytes ?
Your sequence is correct. Just to elaborate a little more, the I2CMCNT1 register should be read on reading every byte. This means you can track exactly when you need to reload the I2CMCNT0 register (i.e. when 256 bytes have been read).
The next revision of the datasheet will correct this.
Note, this sequence is valid for the ADuC7023/ADuC7121/ADuC7122/ADuC7124/ADuC7126 devices also - not just the ADuC7060/61.
The following is the code sequence I used.
uiNumBytesToRead = 400; I2CMCNT0 = 0x100; // Read back 6 bytes I2CADR0 = 0xA1;// + I2C_RD_BIT; // Begin Read sequence from Slave
In the I2C Interrupt handler, the following code should be added:
szRxData[ucRxCount] = I2CMRX; // Read Rx buffer ucRxCount++; I2CCNT = I2CMCNT1; // How many bytes have we read thus far? if (I2CCNT == 0) // If we have 256 bytes read, we need to reload the I2CMCNT0 register I2CMCNT0 = uiNumBytesToRead - 0xFF;
Retrieving data ...