AnsweredAssumed Answered

STM32F0, I2C sends wrong data.

Question asked by h..n on Dec 18, 2013
Latest reply on Dec 19, 2013 by h..n
I have a problem to cinfigure I2C.
This is my code:

#define    PRESC    0x0B
#define    SCLL    0x13
#define    SCLH    0x0F
#define    SDADEL    0x02
#define    SCLDEL    0x04
void I2C_PCF_init()
    GPIOB->AFR[0]|=0x11000000;    //AF1
    RCC->APB1ENR|=RCC_APB1ENR_I2C1EN ;        //enable clock for I2C1
    I2C1->CR1|=I2C_CR1_PE;                    //set PE
    I2C1->CR1&=~I2C_CR1_PE;                    //reset PE
    while(I2C1->CR1&I2C_CR1_PE);            //while PE ==1
    I2C1->TIMINGR|=(PRESC << 28)|(SCLL<<0)|(SCLH<<8)|(SCLDEL<<20)|(SDADEL<<16); //configure for 48Mhz clock
    I2C1->CR1|=I2C_CR1_PE;                    //set PE

void I2C_PCF_send(int adress, int lenght)
    I2C1->CR2|=(adress<<0)|(lenght<<16)|I2C_CR2_ADD10;    //addres SLAVE 10bits
    I2C1->CR2 &=~ I2C_CR2_RD_WRN;                        //write
    I2C1->CR2 |= I2C_CR2_START;
    while(I2C1->ISR&I2C_ISR_TXIS);            //wait for TXDR will be empty and data was send.

No matter what i write after this part:
I2C1->CR2 |= I2C_CR2_START;
I2C sending data like this:

Can somebody tell me what im doing wrong, and why data from buffer TXDR are not sent?