Straightforward I2C Question AW32/QG8

キャンセル
次の結果を表示 
表示  限定  | 次の代わりに検索 
もしかして: 

Straightforward I2C Question AW32/QG8

1,232件の閲覧回数
YeOldeBDM
Contributor III
For the case of the mcu as master and transmitter, the last thing that needs to be done is to send an I2C stop signal. This is accomplished by the code IIC1C_MST=0. But assuming there is alot more to transmit to another slave device, how does the programmer determine when the stop signal has been physically sent on the bus? Are we back to polling after implementing an interrupt driven scheme or back to adding software delay loops?
 
I cant use a delay because IIC1C_MST=0 is in an ISR and there are other ISRs that need low latency.
Theoretically I would like to send a I2C start and some data right after sending that I2C_stop. You can't follow a IIC1C_MST=0 immediately by an IIC1C_MST=1 (a start signal)....on my scope it seems to hang the bus with both SCL and SDA low.
 
I used the app note on how to use the I2C bus for HC08, HCS08, HC12 processors to get started but abandoned it in favor of the qg8 manual. I have also found that app note to be quick and dirty, not checking acks from the slave and not dealing with a loss of arbitration causing an int.
 
 
ラベル(1)
0 件の賞賛
返信
1 返信

467件の閲覧回数
Wings
Contributor I
It's been a while since I did my code for the IIC module (and this was on a GT32A), but I went to have a look because I seem to recall seeing the issue you describe. I use an interrupt driven scheme same as you, and the stop signal is generated within the ISR when the last byte from the buffer has been sent and the ACK checked. It also sets a flag that my main program uses to determine when the IIC module is ready for another transmission, and as soon as that flag is set (meaning the stop condition has just been triggered) I start another IIC transfer by first generating a start condition immediately followed by sending the device address. It's been working fine like this and there are no delay loops. But I think I know where you're going wrong.

When I send the stop condition not only do I set MST=0, I set all bits in the IIC1C register to zero except the IICEN bit (i.e., IIC1C = $80).

When I set the start condition I set IIC1C = $F0 (IICEN=IICIE=MST=TXMODE=1).

Maybe if you tried that you may see a difference.

Hope this helped.
0 件の賞賛
返信