AN1525 STMicroelectronics, AN1525 Datasheet - Page 8

no-image

AN1525

Manufacturer Part Number
AN1525
Description
I2C COMMUNICATION BETWEEN ST52X520 AND EEPROM
Manufacturer
STMicroelectronics
Datasheet
AN1525 - APPLICATION NOTE
4.2.2 Writing Block.
If writing is to be performed, the program will execute the instructions of the block shown in Figure 12 (bit
0 of the FLAG register = 0). The conditional Buffer block verifies when the number of bytes sent from the
2
I
C peripheral of the ST52x520 microcontroller to the memory has achieved the number of bytes indicated
by the user in the BYTE_N variable.
Figure 12. WRITE FLOW BLOCKS
In case the result is positive (i>BufL[=BYTE_N-1]) the STOP condition is sent, ending communication (see
figure 3) and the Re_INIT (2) block is executed, which sets all the bits in the FLAG register to the initial
conditions once again (see Figure 13).
If the number of bytes sent still hasn’t reached the limit, the value of the variable index i in the I2CData_i
block is incremented by one each time. In the same block the initial data defined by the user in the BASE
variable is assigned to the I2CData_i variable. The BASE variable is incremented by the instructions
I2CData = BASE+i and i++ contained in the I2CData_i block. In this manner, the function of the writing
routine is that of sending the growing numeric values that begin with the value specified by the BASE vari-
able, written in the memory locations that begin with the address specified by the W_ADD variable. The
2
Snd_PB block simply sends the byte transferred to the I
C peripheral of the microcontroller, from the
W_SLAD control to port B of the microcontroller.
After each byte is sent (since there is no variation of the value of the FLAG register), the program returns
the control to the Main Program Window through the Retl1 control, and each time an interrupt is generated
2
the I
C routine will return in the writing block (see Figure 12).
8/12

Related parts for AN1525