|
連續(xù)發(fā)送兩個字節(jié)數(shù)據(jù):
Tx1_Idx = 0;
I2cNumbOfBytes2Tansmit = 2;
I2C1_Buffer_Tx[0] = 0x64;
I2C1_Buffer_Tx[1] = 0x00;
Direction = Transmitter;
I2C_GenerateSTART(I2C1, ENABLE);
我的中斷代碼:
void I2C1_EV_IRQHandler(void)
{
switch (I2C_GetLastEvent(I2C1))
{
case I2C_EVENT_MASTER_MODE_SELECT: /* EV5 */
/* Master Transmitter ----------------------------------------------*/
/* Send slave Address for write */
if(Direction == Transmitter)
{
/* Master Transmitter ----------------------------------------------*/
/* Send slave Address for write */
I2C_Send7bitAddress(I2C1, 0x64, I2C_Direction_Transmitter);
}
else
{
/* Master Receiver -------------------------------------------------*/
/* Send slave Address for read */
I2C_Send7bitAddress(I2C1, 0x65, I2C_Direction_Receiver);
}
break;
/* Master Transmitter --------------------------------------------------*/
/* Test on I2C1 EV6 and first EV8 and clear them */
case I2C_EVENT_MASTER_TRANSMITTER_MODE_SELECTED:
/* Send the first data */
I2C_SendData(I2C1, I2C1_Buffer_Tx[Tx1_Idx++]);
I2cNumbOfBytes2Tansmit--;
if (I2cNumbOfBytes2Tansmit == 0)
{
/* In order to not have a TxE event Interrupt */
I2C_ITConfig(I2C1, I2C_IT_BUF, DISABLE);
}
break;
/* Test on I2C1 EV8 and clear it */
case I2C_EVENT_MASTER_BYTE_TRANSMITTING: /* Without BTF, EV8 */
I2C_SendData(I2C1, I2C1_Buffer_Tx[Tx1_Idx++]);
I2cNumbOfBytes2Tansmit--;
if (I2cNumbOfBytes2Tansmit == 0)
{
I2C_ITConfig(I2C1, I2C_IT_BUF, DISABLE);
}
break;
case I2C_EVENT_MASTER_BYTE_TRANSMITTED: /* With BTF EV8-2 */
I2C_ITConfig(I2C1, I2C_IT_BUF, ENABLE);
I2C_GenerateSTOP(I2C1, ENABLE);
Direction = Receiver;
break;
default:
break;
}
}
現(xiàn)在發(fā)現(xiàn)進(jìn)不了EV8-2中斷,如果改成發(fā)送一個字節(jié)數(shù)據(jù)可以進(jìn)入該中斷。
仔細(xì)研究了datasheet,找不出任何問題。
PS:外掛的器件是rx8025實時時鐘芯片。
香水城到不到這里的?21icbbs這幾天一直上不去,非常之郁悶! |
|