cancel
Showing results for 
Search instead for 
Did you mean: 

ack generated once in I2C slave receiver mode

Gaston
Associate III
Posted on August 30, 2011 at 11:07

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 Interrupt

I2C_ITConfig(I2C1,(I2C_IT_TypeDef)(I2C_IT_EVT | I2C_IT_BUF), ENABLE);

// Set I2C IT software priority as highest

ITC_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.

0690X0000060MlSQAU.gif

Thanks in advance,

Gaston

#i2c
1 REPLY 1
Gaston
Associate III
Posted on September 07, 2011 at 08:55

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