cancel
Showing results for 
Search instead for 
Did you mean: 

I2C slave configuration for STM8S208RBT6

EBogo.1
Associate II

Hello, I am trying to use STM8S208RBT6 as an I2C slave. It seems to be configured correctly, yet it doesn't acknowledge its address, and it doesn't get an interrupt. The registers are as follows:

PE_DDR = 0x20;

PE_ODR = 0x20;

PE_CR1 = 0x20;

PE_CR2 = 0x20;

I2C_CR1 = 0x01;

I2C_CR2 = 0x04;

I2C_FREQ = 0x10;

I2C_OARL = 0x28;

I2C_OARH = 0x40;

I2C_ITR = 0x02;

I2C_CCRL = 0x50;

I2C_CCRH = 0x00;

I2C_TRISER = 0x11;

I2C_PECR = 0x00.

What am I missing?

Thank you,

Eric.

1 REPLY 1
EBogo.1
Associate II

OK, it turns out the problem is in the stm8s_i2c.c file provided by the ST. The initialization function in that file writes the I2C 7-bit address into the OARL register as it is, without accounting for the bit 0 of the OARL register. But it needs to shift the 7-bit address left by 1 bit. Thus, the address 0x28 becomes 0x50, and that is what needs to written into OARL. With this change I2C works.