I'm trying to use I2C between an STM32F103C8T6 development board and an Arduino Uno.
However, I always get a HAL_BUSY error when I call HAL_I2C_Master_Transmit
in the code below.
(I used 10K pullup resistors at SCL and SDA) on the STM32 side and a logic level converter between STM32 and Arduino.
How can I send messages from the STM32 to the Arduino?
int main(void)
{
...
MX_I2C1_Init();
char buffer[16];
strcpy((char*) buffer, (const char*) "Test 1");
while (1)
{
HAL_GPIO_TogglePin(GPIOC, GPIO_PIN_14);
HAL_Delay(1000);
if (HAL_I2C_Master_Transmit(&hi2c1, 8, (uint8_t *) buffer, 7, 1000) != HAL_OK)
{
HAL_Delay(1000);
}
Settings (all default):
hi2c1.Instance = I2C1;
hi2c1.Init.ClockSpeed = 100000;
hi2c1.Init.DutyCycle = I2C_DUTYCYCLE_2;
hi2c1.Init.OwnAddress1 = 0;
hi2c1.Init.AddressingMode = I2C_ADDRESSINGMODE_7BIT;
hi2c1.Init.DualAddressMode = I2C_DUALADDRESS_DISABLE;
hi2c1.Init.OwnAddress2 = 0;
hi2c1.Init.GeneralCallMode = I2C_GENERALCALL_DISABLE;
hi2c1.Init.NoStretchMode = I2C_NOSTRETCH_DISABLE;