English
Language : 

7220 Datasheet, PDF (201/303 Pages) Renesas Technology Corp – 8-BIT SINGLE-CHIP MICROCOMPUTER
APPLICATION
5.5 Example of I2C-BUS control by software (M37220M3-XXXSP/FP)
5.5.4 General flowchart
(1) Write processing routine
The processing routine which controls I2C-BUS devices branch to the write processing routine and
the read processing routine. The START condition, the STOP condition and the data output processing
routine are used as the common processing routine.
Œ

Ž


Slave address A
S (W) “BA16”
C
K
A
Sub-address C
K
A
Data
CP
K
Write start
“WRITEDATA”
←Slave address (W) “BA 16”
“WRITE DATA COUNTER”
= “1” (number of write bytes)
“NO ACK COUNTER” = “0”
RAM: WRITEDATA
NO ACK COUNTER
WRITE DATA COUNTER
Flag: F_ACK
START condition
Œ
Data output

No (no ACK)
“F_ACK” = “0”?
Yes (ACK)
“WRITEDATA” ←Sub-address
Data output
Ž
No (no ACK)
STOP condition
“NO ACK COUNTER”
←“NO ACK COUNTER” + 1
“F_ACK” = “0”?
Yes (ACK)
“WRITE DATA
COUNTER” = “0”?
Yes (end)
“NO ACK COUNTER”
≥ “3”?
No (try 3 times)
Yes (give up)
STOP condition
No (not yet)

“WRITEDATA” ←Write data
Bus H

Data output
“WRITE DATA COUNTER”
End
←“WRITE DATA COUNTER” – 1
Fig. 5.5.4 Flowchart of write processing routine
5-28
7220 Group User’s Manual