AnsweredAssumed Answered

I2C not clocking address onto bus in master mode

Question asked by richards.jeremy on Aug 21, 2011

I have set up the input clock , enabled the I2C  peripherial clock and the peripherial itself. I have executed I2C-Init() with the desired parameters.

The peripherial sends a start bit, and recognises this with the SB flag. It loads the required address into the DR but does not clock it out onto the bus.
Looking at the peripherial registers I cannot see anything out of place, but I guess that there must be a flag set somewhere that is preventing the DR from sending the address..........HELP!!

My very basic code snippet is included:

    /*Disable Boot ROM peripheral clock - set by default on reset*/
    CLK->PCKENR2 &=0x00;
    /*=============I2C Peripherial Clock======================*/
    /*SCL pin init*/
    GPIO_Init(GPIOC, GPIO_Pin_1, GPIO_Mode_Out_OD_HiZ_Fast);
    /*SDA pin init*/
    GPIO_Init(GPIOC, GPIO_Pin_0, GPIO_Mode_Out_OD_HiZ_Fast);
    /*Setup input clock to peripherial*/
    CLK_PeripheralClockConfig(CLK_Peripheral_I2C1, ENABLE);
    I2C_Cmd(I2C1, ENABLE);
    /*Initalise I2C Paramters, ~356kHz clk, Own Address 0xA0,std I2C mode,  Fast Mode Duty, Ack Enabled, & bit adresses only acknowledged*/
    I2C_Init(I2C1, 356000, 0x00A0, I2C_Mode_I2C, I2C_DutyCycle_2, I2C_Ack_Enable, I2C_AcknowledgedAddress_7bit);
    while(I2C_GetFlagStatus(I2C1, I2C_FLAG_BUSY));
    I2C_GenerateSTART(I2C1, ENABLE);                                           // START=1, generate start
  while(!(I2C_GetFlagStatus(I2C1, I2C_FLAG_SB)));          // Wait for start bit detection (SB)
    I2C_ClearFlag(I2C1, I2C_FLAG_SB);
    /*Send slave address to DR ready to TX*/
        I2C_Send7bitAddress(I2C1, SLAVE_ADDRESS, I2C_Direction_Transmitter);
        while(!(I2C_GetFlagStatus(I2C1, I2C_FLAG_ADDR)));                            // Wait for address ack (ADDR)
        I2C_ClearFlag(I2C1, I2C_FLAG_ADDR);