|
7220 Datasheet, PDF (197/303 Pages) Renesas Technology Corp – 8-BIT SINGLE-CHIP MICROCOMPUTER | |||
|
◁ |
APPLICATION
5.4 Example of I2C-BUS interface control (M37221Mx-XXXSP/FP)
(2) Read processing routine
Â
Â
Â
Â
Slave address A
S (W) âA016â
C
K
Sub-address
A
C
R
KS
Read start
Initialization
S2 (address 00DB 16) ââ110001012â
S1D (address 00DA 16) ââ010010002â
IICE (bit6 at address 00FE 16) ââ0â
S1 (address 00D9 16) ââ000100002â
Â
Â
Â
A: Accumulator
S0: I2C data shift register
Slave address A
A
(R) âA116â
C
K
Data
CP
K
S1: I2C status register
S2: I2C clock control register
S1D: I2C control register
IICE: Multi-master I 2C interface
interrupt enable bit
BB: Bus busy flag
TRX: Communication mode
specification bit
ACK BIT: ACK bit
PIN: I2C-BUS interface interrupt
request bit
Disable multi-master I 2C-BUS interface. RS: Restart condition
Setting for outputting the START condition
in data output processing routine.
(A)âSlave address (W) âA0 16â
Data output
S1 (address 00D9 16) ââ001000002â
(A)âSlave address (R) âA1 16â
Data output
TRX (bit 6 at address 00D9 16) ââ0â
ACK BIT (bit 6 at address 00DB 16) ââ0â
ÂÂÂ
Transmit the START condition, slave
address (W) , and sub-address.
ÂÂ
Transmit the RESTART condtion and
slave address (R).
Set to receive mode
Set ACK return mode.
Immediately before
No
the last receive byte?
Yes
ACK BIT (bit 6 at address 00DB 16)ââ1â
Set to non-ACK return mode.
No
End of reception of
S0 (address 00D7 16)ââFF16â
Preparation for judging of timeout.
Timeout ? (See note 2)
ÂInput start
(Set dummy data to
generate clock.)
Yes
the last receive byte
Yes
After data is received, no
acknowledge bits are
generated, but the STOP
condition is sent by the
master, completing this
read operation.
No
Waiting receive end
PIN (bit 4 at address 00D9 16)â â1â?
No (not end)
Yes (end)
Store recive data to internal RAM
Within 10
I
ââ1â
machine
S1 (address 00F8 16) ââ110000002â
cycles
S1 (address 00F8 16) ââ110100002â
I
ââ0â
ÂTransmit the STOP condition.
Note 1: Be sure to set between S1
and S1 within 10 machine cycles.
End
Note 2: The timeout count is performed by software with interrupts, such as timers. Accordingly, if receive
operation is not completed due to various influences, the loop continues. Therefore, if receive
operation does not complete within a certain time, I 2 C-BUS access is stopped by outputting STOP
condition. If I 2C-BUS access is stopped by timeout, the obtained data is incorrect data.
Fig. 5.4.5 Flowchart of read processing routine
5-24
7220 Group Userâs Manual
|
▷ |