15. USI
A96G140/A96G148/A96A148 User’s manual
180
1.
If the main operating clock (SCLK) of the system is slower than that of SCLn, load value
0x00 into USInSDHR to make SDAn change within one system clock period from the
falling edge of SCLn. Note that the hold time of SDAn is calculated by SDAH x period of
SCLK where SDAH is multiple of number of SCLK coming from USInSDHR. When the
hold time of SDAn is longer than the period of SCLK, I2C (slave) cannot transmit serial
data properly.
2.
Enable I2C by setting USInMS[1:0] bits in USInCR1, IICnIEbit in USInCR4 and USInEN
bit in USInCR2. This provides main clock to the peripheral.
3.
When a START condition is detected, I2C receives one byte of data and compares it with
USInSLA[6:0] bits in USInSAR. If the GCALLn bit in USInSAR is enabled, I2Cn compares
the received data with value 0x00, the general call address.
4.
If the received address does not equal to SLAn bits in USInSAR, I2C enters idle state i.e.,
waits for another START condition. Else if the address equals to SLAn bits and the
ACKnEN bit is enabled, I2C generates SSELn interrupt and the SCLn line is held LOW.
Note that even if the address equals to SLAn bits, when the ACKnEN bit is disabled, I2C
enters idle state. When SSELn interrupt occurs and I2C is ready to receive data, write
arbitrary value to USInST2 to release SCLn line.
5.
Byte of data is being received.
6.
In this step, I2C generates TENDn interrupt and holds the SCLn line LOW regardless of
the reception of ACK signal from master. Slave can select one of the following cases.
Case 1: No ACK signal is detected (ACKnEN=0) and I2C waits STOP or repeated START
condition.
Case 2: ACK signal is detected (ACKnEN=1) and I2C can continue to receive data from
master.
After doing one of the actions above, write arbitrary value to USInST2 to release SCLn
line. For the case 1, move to step 7 to terminate communication. For the case 2, move to
step 5. In either case, a repeated START condition can be detected. For that case, move
step 4.
7.
This is the final step for slave receiver function of I2C, handling STOP interrupt. The
STOPCn bit indicates that data transfer between master and slave is over. To clear
USInST2, write any value to USInST2. After this, I2C enters idle state.