2018-05-22 09:44 AM
Hi to all.
I'm trying to use I2C peripheral of STM32F103C8T6. I'm using a BluePill board. First of all, I know that this problem was published in other forums and so, but after trying other solutions, I didn't find the way to make it work.
I'm using the last STM32CubeMX firmware 1.6.1 V for STM32F103C8Tx.
I tried to make an example that uses I2C in order to make a library for an SSD1306 I2C display.
The example consists of this:
while (1)
{ HAL_GPIO_TogglePin(GPIOC, 1<<13); HAL_Delay(1000); /* USER CODE END WHILE */ uint8_t buf = 0; volatile HAL_StatusTypeDef status; status = HAL_I2C_Master_Transmit(&hi2c1, 0x3c<<1, &buf,1, 100); HAL_I2C_IsDeviceReady(&hi2c1, 0x3c<<1, 100,200); try_unlock_i2c(); status = HAL_I2C_Master_Transmit(&hi2c1, 0x3c<<1, &buf,1,100); HAL_I2C_ClearBusyFlagErrata_2_14_7(&hi2c1); /* USER CODE BEGIN 3 */ }Here, I call HAL_I2C_Master_Transmit function while the device is connected to the display, just in order to see the wave in a logic analyzer and in the debugger, but the fact is that no wave is shown.
Just to make sure the program was running, I launched the debugger and I read the status variable. With this, I saw that the function is returning HAL_BUSY. It happens to me almost every time I use the I2C peripheral.
I did my research, and I know about the errata thing, so I tried to implement some solutions I found on the Internet in order to clear the BUSY flag.
Please find attached my code.
I'm still learning this amazing microcontroller, so it may be a 'basic' thing.
Thanks in advance.
EDIT: Well, this is very strange, but right now it started to work properly. If anyone knows a possible reason, a reply would be appreciated, because it can happen another time.
#i2c #stm32f1 #stm32f103 #i2c-dma #busy #errata #ssd1306 #i2c-busy #busy-flag2018-08-08 02:11 PM
Can't help you, bumping you off my feed