Skip to main content
TomᨠMat?jka
Associate II
March 28, 2017
Question

I2C - generated CubeMX

  • March 28, 2017
  • 1 reply
  • 1239 views
Posted on March 28, 2017 at 22:56

Hello, I still tried with I2C on nucleo F401RE. I am use STM32CubeMx for generate files, but my program is not working. I  want send three bytes on I2C in blovking mode. This is my code: 

I2C not working, still is log. 0 on SDA and SCL. Please help me.

In rar. is all files.

int main(void)

{

/* USER CODE BEGIN 1 */

/* USER CODE END 1 */

/* MCU Configuration----------------------------------------------------------*/

/* Reset of all peripherals, Initializes the Flash interface and the Systick. */

HAL_Init();

/* Configure the system clock */

SystemClock_Config();

/* Initialize all configured peripherals */

MX_GPIO_Init();

MX_I2C1_Init();

/* USER CODE BEGIN 2 */

/* USER CODE END 2 */

uint8_t buffer[3]={0x33,0x87,0X76};

while (1)

{

HAL_I2C_Master_Transmit(&hi2c1,0X40,buffer,3,10);

HAL_Delay(100);

HAL_GPIO_TogglePin(GPIOA,GPIO_PIN_5);

/* USER CODE BEGIN 3 */

}

/* USER CODE END 3 */

}

#hal #smt32-nucleo #cube-mx #i2c
This topic has been closed for replies.

1 reply

choirul Kusumohadi
Visitor II
February 27, 2018
Posted on February 27, 2018 at 11:52

Hallo, have u done with this issue?

Andrew Neil
Super User
February 27, 2018
Posted on February 27, 2018 at 13:07

After very nearly a year, one would hope so!

A complex system that works is invariably found to have evolved from a simple system that worked.A complex system designed from scratch never works and cannot be patched up to make it work.
choirul Kusumohadi
Visitor II
February 28, 2018
Posted on February 28, 2018 at 02:27

I has some like a bug in CubeMX,

Condition:

I use STM32l073Rz,

When I generated a code with setup I2C1 :

Primary Slave Address : 0x02 in CubeMX,

Primary Address Length Selection : 7 bit.

But output script shown 0x04,

When I change 0x01, output script shown 0x02.