|
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
|
▷ |