2018-09-14 08:46 AM
Hello,
I want to implement an I2C slave on the Nucleo board with interrupt functionality. As a master, I have an Arduino ESP8266. The master queries data from the nucleo. Now I'm not so familiar with the STM32 and Nucelo and HAL. Is there a giagram or similar on which I can see what triggers the I2C interrupt? I want to transfer the data reliably. For a first test, I just want to toggle a pin. Do you have tips or hints for me.
/* I2C1 init function */
static void MX_I2C1_Init(void)
{
hi2c1.Instance = I2C1;
hi2c1.Init.Timing = 0x10909CEC;
hi2c1.Init.OwnAddress1 = 8;
hi2c1.Init.AddressingMode = I2C_ADDRESSINGMODE_7BIT;
hi2c1.Init.DualAddressMode = I2C_DUALADDRESS_DISABLE;
hi2c1.Init.OwnAddress2 = 0;
hi2c1.Init.OwnAddress2Masks = I2C_OA2_NOMASK;
hi2c1.Init.GeneralCallMode = I2C_GENERALCALL_ENABLE;
hi2c1.Init.NoStretchMode = I2C_NOSTRETCH_ENABLE;
if (HAL_I2C_Init(&hi2c1) != HAL_OK)
{
_Error_Handler(__FILE__, __LINE__);
}
/**Configure Analogue filter
*/
if (HAL_I2CEx_ConfigAnalogFilter(&hi2c1, I2C_ANALOGFILTER_ENABLE) != HAL_OK)
{
_Error_Handler(__FILE__, __LINE__);
}
/**Configure Digital filter
*/
if (HAL_I2CEx_ConfigDigitalFilter(&hi2c1, 0) != HAL_OK)
{
_Error_Handler(__FILE__, __LINE__);
}
}
/* USER CODE BEGIN 4 */
void HAL_I2C_AddrCallback(I2C_HandleTypeDef *hi2c1, uint8_t TransferDirection, uint16_t AddrMatchCode)
{
HAL_GPIO_TogglePin(GPIOB,D6_Pin);
}
/* USER CODE END 4 */
2018-09-20 03:00 AM
Hello @Christof Jähne ,
to understand how to setup I2C slave communication using interrupt mode you can refer to the I2C example provided in the STM32Cube_FW_L4 package at the following path:
Projects\NUCLEO-L476RG\Examples\I2C\I2C_TwoBoards_ComIT
2019-03-24 09:37 AM
Hello.
I have been trying to communicate a board NUCLEOL432 and a board NUCLEOF411 via the I2C bus , using the F411 as master and the L432 as a slave, but when activating the module I2c on the board NUCLEOL432 in interrupt mode I have not been able to establish a communication. I have been looking for the path that directs me to (Projects \ NUCLEO-L476RG \ Examples \ I2C \ I2C_TwoBoards_ComIT)
But I have not found it.
I'd appreciate your help.
2019-03-25 05:36 AM
Hello,
firmware package containing the example can be found at this link: STM32CubeL4
Here you should find the mentioned project.