145
MC96F8204
ABOV Semiconductor Co., Ltd.
11.9.8 Operation
The I2C is byte-oriented and interrupt based. Interrupts are issued after all bus events except for a transmission of a
START condition. Because the I2C is interrupt based, the application software is free to carry on other operations
during a I2C byte transfer.
Note that when a I2C interrupt is generated, IICIFR flag in IIFLAG register is set, it is cleared when all interrupt source
bits in the I2CSR register are cleared to “0b”.
When I2C interrupt occurs, the SCL line is hold LOW until clearing
“0b”
all interrupt source bits in I2CSR register. When the IICIFR flag is set, the I2CSR contains a value indicating the
current state of the I2C bus. According to the value in I2CSR, software can decide what to do next.
I2C can operate in 4 modes by configuring master/slave, transmitter/receiver. The operating mode is configured by a
winning master. A more detailed explanation follows below.
11.9.8.1
Master Transmitter
To operate I2C in master transmitter, follow the recommended steps below.
1.
Enable I2C by setting IICEN bit in I2CCR. This provides main clock to the peripheral.
2.
Load SLA+W into the I2CDR where SLA is address of slave device and W is transfer direction from the
viewpoint of the master. For master transmitter, W is
‘0’. Note that I2CDR is used for both address and data.
3.
Configure baud rate by writing desired value to both I2CSCLR and I2CSCHR for the Low and High period of
SCL line.
4.
Configure the I2CSDHR to decide when SDA changes value from falling edge of SCL. If SDA should change
in the middle of SCL LOW period, load half the value of I2CSCLR to the I2CSDHR.
5.
Set the STARTC bit in I2CCR. This transmits a START condition. And also configure how to handle interrupt
and ACK signal. When the STARTC bit is set, 8-bit data in I2CDR 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 9
th
high period of SCL. 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 MLOST bit in I2CSR is set, and I2C waits in idle state or can be operate as an addressed slave.
To operate as a slave when the MLOST bit in I2CSR is set, the ACKEN bit in I2CCR must be set and the
received 7-bit address must equal to the SLA bits in I2CSAR. In this case I2C operates as a slave transmitter
or a slave receiver (go to appropriate section). In this stage, I2C holds the SCL 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 regardless of the reception of ACK signal from slave.
1) Master receives ACK signal from slave, so continues data transfer because slave can receive more data
from master. In this case, load data to transmit to I2CDR.
2) Master stops data transfer even if it receives ACK signal from slave. In this case, set the STOPC bit in
I2CCR.
Содержание MC96F8104M
Страница 13: ...13 MC96F8204 ABOV Semiconductor Co Ltd 4 Package Diagram Figure 4 1 20 Pin SOP Package...
Страница 14: ...14 MC96F8204 ABOV Semiconductor Co Ltd Figure 4 2 20 Pin TSSOP Package...
Страница 15: ...15 MC96F8204 ABOV Semiconductor Co Ltd Figure 4 3 16 Pin SOPN Package...
Страница 16: ...16 MC96F8204 ABOV Semiconductor Co Ltd Figure 4 4 10 Pin SSOP Package...
Страница 17: ...17 MC96F8204 ABOV Semiconductor Co Ltd Figure 4 5 8 Pin SOP Package...