
A96G140/A96G148/A96A148 User’s manual
15. USI
177
15.19.2
USIn I2C master receiver
To operate I2C in master receiver, follow the recommended steps below:
1.
Enable I2C by setting USInMS[1:0] bits in USInCR1and USInEN bit in USInCR2. This
provides main clock to the peripheral.
2.
Load SLAn+R into the USInDR where SLA is address of slave device and R is transfer
direction from the viewpoint of the master. For master receive
r, R is ‘1’. Note that USInDR
is used for both address and data.
3.
Configure baud rate by writing desired value to both USInSCLR and USInSCHR for the
Low and High period of SCLn line.
4.
Configure the USInSDHR to decide when SDAn changes value from falling edge of SCLn.
If SDAn should change in the middle of SCLn LOW period, load half the value of
USInSCLR to the USInSDHR.
5.
Set the STARTCn bit in USInCR4. This transmits a START condition. And also configure
how to handle interrupt and ACK signal. When the STARTCn bit is set, 8-bit data in
USInDR is transmitted out according to the baud-rate.
6.
This is ACK signal processing stage for address packet transmitted by master. When 7-
bit address and 1-bit transfer direction is transmitted to target slave device, the master
can know whether the slave acknowledged or not in the 9th high period of SCLn. If the
master gains bus mastership, I2C generates GCALL interrupt regardless of the reception
of ACK from the slave device. When I2C loses bus mastership during arbitration process,
the MLOSTn bit in USInST2 is set, and I2C waits in idle state or can be operate as an
addressed slave. To operate as a slave when the MLOSTn bit in USInST2 is set, the
ACKnEN bit in USInCR4 must be set and the received 7-bit address must equal to the
USInSLA[6:0] bits in USInSAR. In this case I2C operates as a slave transmitter or a slave
receiver (go to appropriate section). In this stage, I2C holds the SCLn LOW. This is
because to decide whether I2C continues serial transfer or stops communication. The
following steps continue assuming that I2C does not lose mastership during first data
transfer.
I2C (Master) can choose one of the following cases according to the reception of ACK
signal from slave:
Case 1: Master receives ACK signal from slave, so continues data transfer because slave
can prepare and transmit more data to master. Configure ACKnEN bit in USInCR4 to
decide whether I2C ACKnowledges the next data to be received or not.