cancel
Showing results for 
Search instead for 
Did you mean: 

I2C initialisation problem STM32F0308 - Discovery

rviglione
Associate
Posted on February 23, 2016 at 22:56

Hello all,

I'm trying to get both I2C peripherals to work on my STM32F0308 - Discovery board. I am using OpenSTM32 toolchain with Eclipse Mars. I downloaded the MxCube example projects for the F0 and loaded the I2C example with interrupts. To initialize both I2C peripherals, I tried to modify theHAL_I2C_MspInit() functionin the following manner:

void HAL_I2C_MspInit(I2C_HandleTypeDef *hi2c)
{
if (hi2c->Instance == I2C1)
{
// Do stuff for I2C1
}
else
{
// Do stuff for I2C2 
}
}

So here is my problem. In my initilisation, I have the following line; GPIO_InitStruct.Pin = I2Cx_SCL_PIN; When I go to the declaration ofI2Cx_SCL_PIN, it points to the main.h file. So I changed the I2Cx portion toI2C1, and dupliacted all the #define to have I2C2 instances aswell. However, when I go back to my code and change the line to: GPIO_InitStruct.Pin = I2C1_SCL_PIN; Eclipse complains and says that I2C1_SCL_PIN isn't declared. When I change it back to I2C x_SCL_PIN and go to the declaration, it goes to and highlights I2C 1_SCL_PIN. Also, if I delete the #define altogether, it still points to something inside my main.h file, even though the #define no longer exists. Has anyone encountered similar problems and figured out why this is happening? #init #i2c #hal #discovery #f0
1 REPLY 1
rviglione
Associate
Posted on February 23, 2016 at 23:16

Fixed my problem! Had to rebuild my C/C++ index in eclipse because I changed my header file...