AnsweredAssumed Answered

I2C3 configuration stm32F4Discovery

Question asked by Kenny on Jun 22, 2013
Latest reply on Jun 23, 2013 by Kenny
Hi everyone,

I'm trying to configure I2C3 on the stm32f4 discovery board but i end up
in the hard fault handler at I2C_Init.

I am doing something weird i'm sure, any ideas?

void I2C_Config(void)
{
    GPIO_InitTypeDef GPIO_InitStruct;
    I2C_InitTypeDef I2C_InitStruct;
 
 
    RCC_APB1PeriphClockCmd(RCC_APB1Periph_I2C3, ENABLE);
 
    RCC_AHB1PeriphClockCmd(RCC_AHB1Periph_GPIOA, ENABLE);
 
    GPIO_InitStruct.GPIO_Pin = GPIO_Pin_8 | GPIO_Pin_9;
    GPIO_InitStruct.GPIO_Mode = GPIO_Mode_AF;
    GPIO_InitStruct.GPIO_Speed = GPIO_Speed_50MHz;
    GPIO_InitStruct.GPIO_OType = GPIO_OType_OD;
    GPIO_InitStruct.GPIO_PuPd = GPIO_PuPd_UP;
    GPIO_Init(GPIOA, &GPIO_InitStruct);
 
    // Connect I2C3 pins to AF
    GPIO_PinAFConfig(GPIOA, GPIO_PinSource8, GPIO_AF_I2C3); // SCL
    GPIO_PinAFConfig(GPIOA, GPIO_PinSource9, GPIO_AF_I2C3); // SDA
 
    // configure I2C3
    I2C_InitStruct.I2C_ClockSpeed = 100000;
    I2C_InitStruct.I2C_Mode = I2C_Mode_I2C;
    I2C_InitStruct.I2C_DutyCycle = I2C_DutyCycle_2;
    I2C_InitStruct.I2C_OwnAddress1 = 0x00;
    I2C_InitStruct.I2C_Ack = I2C_Ack_Disable;
    I2C_InitStruct.I2C_AcknowledgedAddress = I2C_AcknowledgedAddress_7bit;
    I2C_Init(I2C3, &I2C_InitStruct);
 
    // enable I2C3
    I2C_Cmd(I2C3, ENABLE);
   
   
   
}



Outcomes