cancel
Showing results for 
Search instead for 
Did you mean: 

I2C not ready (STM32CubeMX STM32F1 Makefile project)

jankostial9
Associate II
Posted on March 23, 2018 at 11:46

Hello,

I am trying to use the character LCD with I2C expander together with BluePill bard (STM32F103C8T6).

I have the Makefile project generated by STM32CubeMX (latest 4.25).

Because LCD was not working (not initialized) I am trying to find if I2C interface is OK.

So I have added the following lines to the main.c (2 short blinks with LED connected to PC13 pin when I2C is not ready - tested approx every 2 sec):

/* USER CODE BEGIN 2 */

while (HAL_I2C_IsDeviceReady (&hi2c1, 0x27, 5, 1000) != HAL_OK) {

HAL_GPIO_WritePin (PC13_LED_GPIO_Port, PC13_LED_Pin, 1);

HAL_Delay (200);

HAL_GPIO_WritePin (PC13_LED_GPIO_Port, PC13_LED_Pin, 0);

HAL_Delay (10);

HAL_GPIO_WritePin (PC13_LED_GPIO_Port, PC13_LED_Pin, 1);

HAL_Delay (200);

HAL_GPIO_WritePin (PC13_LED_GPIO_Port, PC13_LED_Pin, 0);

HAL_Delay (10);

HAL_GPIO_WritePin (PC13_LED_GPIO_Port, PC13_LED_Pin, 1);

HAL_Delay (1500);

}

And yes, LED is blinking - so it means I2C is not ready.

What I need to do to have the I2C working?

Hardware and I2C address 0x27 is correct, because the Arduino STM32 project using LiquidCrystal_i2c library is working.

Complete project attached.

Versions used: STM32CubeMX 4.25, STM32Cube fw F1 1.6.1

Thanks and regards

Jan

#i2c #stm32cubemx-4.25 #makefile #stm32cubef1
0 REPLIES 0