2008-05-06 06:07 PM
I2C master transmitting STOP
2011-05-17 03:34 AM
How should I finish I2C master transmitting? I use this interrupt routine:
Code:
void I2C1_EV_IRQHandler(void) { u32 le=I2C_GetLastEvent(I2C1); switch (le) { /* Test on I2C1 EV5 and clear it */ case I2C_EVENT_MASTER_MODE_SELECT: /* Send I2C1 slave Address for write */ I2C_Send7bitAddress(I2C1, I2C2_SLAVE_ADDRESS7, I2C_Direction_Transmitter); break; /* Test on I2C1 EV6 and first EV8 and clear them */ case I2C_EVENT_MASTER_TRANSMITTER_MODE_SELECTED: /* Send the first data */ Tx_Idx--; I2C_SendData(I2C1, *I2C1_Buffer_Tx++); //EV8 just after EV6 break; /* Test on I2C1 EV8 and clear it */ case I2C_EVENT_MASTER_BYTE_TRANSMITTED: if(Tx_Idx) { /* Transmit buffer data */ Tx_Idx--; I2C_SendData(I2C1, *I2C1_Buffer_Tx++); } else { I2C_GenerateSTOP(I2C1, ENABLE); } break; default: break; } } However, I receive next interrupt afterCode:
I2C_GenerateSTOP(I2C1, ENABLE);
How should I regullary stop transmitting? I want to stay in master mode, because after packet is transmitted, next packet should continue.2011-05-17 03:34 AM
I've turned off interrupts just before issuing the STOP command. This seems to work; to start another transfer, you have to turn on interrupts and issue a START command.
Cheers --Kurt