I2C - generated CubeMX
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