0

stm32 HAL I2C Problem

I am using a Nucleos f103rb board and want to programm a simple i2c communication with a 0.91 oled i2c display. In order to see some data from the i2c I connected my oszi to sda and scl. But when I run my program I only see a permament 3.3V voltage on both pins. I have tried to get the fault, so I looked up what the state of HAL_I2C_Master_Transmit is and it is always busy. I have set the right pins of I2C in MXCube, and enable I2C, so what I am doing wrong? Thanks for answering.

29th Mar 2020, 5:22 PM
ld programs
1 Antwort
0
Here is my main code: int main(void) { /* USER CODE BEGIN 1 */ HAL_StatusTypeDef ret; uint16_t address = 1; /* USER CODE END 1 */ /* MCU Configuration--------------------------------------------------------*/ /* Reset of all peripherals, Initializes the Flash interface and the Systick. */ HAL_Init(); /* USER CODE BEGIN Init */ /* USER CODE END Init */ /* Configure the system clock */ SystemClock_Config(); /* USER CODE BEGIN SysInit */ /* USER CODE END SysInit */ /* Initialize all configured peripherals */ MX_GPIO_Init(); MX_I2C1_Init(); MX_USART2_UART_Init(); /* USER CODE BEGIN 2 */ HAL_UART_Transmit(&huart2, (uint8_t*)("\ronline\n\r\n"), strlen("\ronline\n\r\n"), HAL_MAX_DELAY); /* USER CODE END 2 */ /* Infinite loop */ /* USER CODE BEGIN WHILE */ while (1) { /* USER CODE END WHILE */ /* USER CODE BEGIN 3 */ ret = HAL_I2C_Master_Transmit(&hi2c1, address, (uint8_t*)0xE3, 1, HAL_MAX_DELAY); if ( ret == HAL_ERROR ) { HAL_UART_Transmit(&huart2, (uint8_t*)("\rError\n"), strlen("\rError\n"), HAL_MAX_DELAY); address++; } else if(ret == HAL_BUSY) { HAL_UART_Transmit(&huart2, (uint8_t*)("\rBusy\n"), strlen("\rBusy\n"), HAL_MAX_DELAY); } else { HAL_UART_Transmit(&huart2, (uint8_t*)("\rFound\n"), strlen("\rFound\n"), HAL_MAX_DELAY); } } /* USER CODE END 3 */ }
29th Mar 2020, 5:23 PM
ld programs