AN1328 STMicroelectronics, AN1328 Datasheet - Page 7

no-image

AN1328

Manufacturer Part Number
AN1328
Description
I2C COMMUNICATION PROTOCOL WRITTEN IN FUZZYSTUDIOTM4.0 FOR ST52X430
Manufacturer
STMicroelectronics
Datasheet
AN1328 - APPLICATION NOTE
Figure 9. The “Write” subroutine
Now, the program waits for an acknowledge from the memory. In this phase of communication (that is,
following a Start command), the memory could be busy, as it could be completing a previous operation of
write (recall that during an internal write cycle the memory is unusable). As the memory datasheet speci-
fies, if there is no acknowledge, the master has to restart and re-transmit the device selector. If acknowl-
edged, then the master sends the address specified by Address and, then, the Data . For the two
successive Write subroutines, the program doesn’t check for an acknowledge although the 9th clock cycle
has to be generated in any case. At the end, the Stop subroutine ends the communication process.
The Write_Byte , Start1 and Stop subroutines are described and commented in the in the FuzzyStu-
dio™4.0 project called " ByteWrite.fs4 " you can download from the web.
5.2 Program READ
The main program sets the value for the auxiliary register REG_CONF4_IM (in our case we suppose that
the PORT_A is configured as input) and, then, what the user has to do is just provide the value for the
variable Address (from 0 to 255) whose content has to be read and loaded in the variable Data .
As only the Random Read mode was implemented, the Read procedure is very similar to that of Write .
Hence, as shown in Figure 10, we note that the first part of the program is like the one analyzed above. In
fact, after the device selector byte (with the bit R/W set to 0) has been acknowledged, we have to send to
the memory a dummy byte specifying the address to be read. After that, we send a device selector with
the R/W set to 1 and then the micro configures PA6 in input to read the content of the selected address.
7/9

Related parts for AN1328