15. Combination of USART, SPI, and I2C (USI)
A96G150 User's manual
200
15.19
USIn I2C 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 an I2C byte transfer.
Note that when an I2C interrupt is generated, IICnIFR flag in USInCR4 register is set, it is cleared by
writing any value to USInST2. When I2C interrupt occurs, the SCLn line is hold LOW until writing any
value to USInST2. When the IICnIFR flag is set, the USInST2 contains a value indicating the current
state of the I2C bus. According to the value in USInST2, 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.
15.19.1
USIn I2C master transmitter
To operate I2C in master transmitter, follow the recommended steps below:
1.
Enable I2C by setting USInMS[1:0] bits in USInCR1 and USInEN bit in USInCR2. This provides
main clock to the peripheral.
2.
Load SLAn+W into the USInDR where SLAn is address of slave device and W is transfer
direction from the viewpoint of the
master. For master transmitter, W is ‘0’. 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.
Содержание A96G150
Страница 126: ...12 Timer 0 1 2 3 4 5 A96G150 User s manual 126 Figure 43 16 bit Timer Counter Mode Operation Example...
Страница 136: ...12 Timer 0 1 2 3 4 5 A96G150 User s manual 136 Figure 51 16 bit Timer Counter Mode Operation Example...
Страница 147: ...A96G150 User s manual 12 Timer 0 1 2 3 4 5 147 Figure 59 16 bit Timer Counter Mode Operation Example...
Страница 157: ...A96G150 User s manual 12 Timer 0 1 2 3 4 5 157 Figure 67 16 bit Timer Counter Mode Operation Example...
Страница 171: ...A96G150 User s manual 14 12 bit ADC 171 Figure 79 ADC Operation Flow Sequence...
Страница 333: ...A96G150 User s manual Revision history 333 Revision history Revision Date Notes 1 00 2022 06 22 First creation...