2011-08-30 02:07 AM
Hello,
I'm using STM8L152C6 as a slave I2C device. I'm able to receive the first byte with acknowledge but successive rx data go along with NACKs. Here's my I2C configuration:CLK_PeripheralClockConfig(CLK_Peripheral_I2C1, ENABLE);
CLK_SYSCLKDivConfig(CLK_SYSCLKDiv_1);I2C_DeInit(I2C1);I2C_Init(I2C1, 80000,DATACOMM_SLAVE_ADDRESS<<1, I2C_Mode_I2CI2C_DutyCycle_2, I2C_Ack_Enable, I2C_AcknowledgedAddress_7bit);// Enable I2C InterruptI2C_ITConfig(I2C1,(I2C_IT_TypeDef)(I2C_IT_EVT | I2C_IT_BUF), ENABLE); // Set I2C IT software priority as highestITC_SetSoftwarePriority(I2C1_IRQn, ITC_PriorityLevel_3);How should assert successive ACKs after receiving the first byte?Could someone help me with this issue?I also attach a screenshot of the I2C timing for further information.Thanks in advance,Gaston #i2c2011-09-06 11:55 PM
I've finally found a workaround. After sending the 3 bytes to the host and setting ENABLE the Stop bit I add these two lines:
while (I2C_GetFlagStatus(I2C1, I2C_FLAG_STOPF));
I2C_GenerateSTOP(I2C1, DISABLE); Regards, Gaston