cancel
Showing results for 
Search instead for 
Did you mean: 

I2C protocol STOP condition not detected in slave-transmission mode

rgovindappa9
Associate II
Posted on March 24, 2011 at 12:00

I2C protocol STOP condition not detected in slave-transmission mode

4 REPLIES 4
rgovindappa9
Associate II
Posted on May 17, 2011 at 15:12

Here is my Slave transmitter part in 

@far @interrupt void I2C_IRQHandler(void)  /* I2C Interrupt handler*/

is as follows

/*SLAVE TRANSMITTER*/

/*Data transmited from slave to master*/

/*EV3-1: TxE=1, shift register empty, data register empty, write DR register.*/

if(I2C_CheckEvent(I2C_EVENT_SLAVE_BYTE_TRANSMITTED))

  {

/*Acknowledge failure*/

/*EV3-2: AF=1, AF is cleared by writing ‘0’ in AF bit of SR2 register*/

if(I2C_CheckEvent(I2C_EVENT_SLAVE_ACK_FAILURE))

{

I2C_ClearFlag(I2C_FLAG_ACKNOWLEDGEFAILURE);

}

/*EV3: TxE=1, cleared by writing DR; shift register not empty*/

I2C_SendData(SomeData);

I2C_ClearFlag(I2C_FLAG_TRANSFERFINISHED);

}

rgovindappa9
Associate II
Posted on May 17, 2011 at 15:12

Here is Master-receiver implementation in I2C interrupt service routine

 /*MASTER RECEIVER, read-write byte=1*/

  else if(I2C_CheckEvent(I2C_EVENT_MASTER_BYTE_RECEIVED))

  {

  /*EV7_1: RxNE=1, cleared by reading DR register, program ACK=0 and STOP request*/

  if(SECOND_LAST_BYTE)

  {

   I2C_AcknowledgeConfig(I2C_ACK_NONE);

   I2C_CurrentReadData = I2C_ReceiveData(); 

  }  

  else if(LAST_BYTE)

  {

   I2C_CurrentReadData = I2C_ReceiveData();

   I2C_GenerateSTOP(ENABLE);

  }

  //EV7: RxNE=1, cleared by reading DR register

  else

  {  

   I2C_CurrentReadData = I2C_ReceiveData();

  }

  I2C_ClearFlag(I2C_FLAG_RXNOTEMPTY);  

 }
rgovindappa9
Associate II
Posted on May 17, 2011 at 15:12

The ACK failure is triggered in the slave when master sets ACK bit to 0

rgovindappa9
Associate II
Posted on May 17, 2011 at 15:12

I am struggling for the last one week and have tried various combinations and permutations and have ran out of ideas - I have a requirement to implement Master-receiver and Slave-transmitter as interrupt state machines as outlined by the STM8S datasheet, polling is not an option. Any help will be highly appreciated