cancel
Showing results for 
Search instead for 
Did you mean: 

I2C master transmitting STOP

juraj
Associate II
Posted on May 07, 2008 at 03:07

I2C master transmitting STOP

2 REPLIES 2
juraj
Associate II
Posted on May 17, 2011 at 12:34

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 after

Code:

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.

kurt2
Associate
Posted on May 17, 2011 at 12:34

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