Posted on November 29, 2017 at 11:14I encountered a strange I2C - UART Collision problem and wonder if there is something I missed in the Documentation.
Problem and what I tried to solve it:
- I2C and UART work fine and permanent when I initialize only one of them
- With both initialized: I2C fails permanently with a HAL_TIMEOUT (waiting for the Busy-Flag to be reset) as soon as the first byte via UART was received (failing function HAL_I2C_Master_Transmit(...) from file stm32f4xx_hal_i2c.c)
- The I2C Lines (inspected via Oscilloscope) look good all the time.
- Interrupts for I2C or UART can be enabled or not - does not make a difference
- Multiple UARTs on different pins were tried (UART2, UART4, UART7) - Problem was always the same
- I have not tried to change to another I2C (from I2C1) because the hardware makes this much more difficult than switching the UARTs
- I switched to another Nucleo-F429ZI-Board - no difference
- Dirty workaround: As soon as I encounter a HAL_TIMEOUT on I2C, I 'deinit' and 'init' I2C again - which looks like very bad style but seems to work for now.
Hardware configuration and programming environment:
- Nucleo-F429ZI-Board (tested with two boards)
- Control via USB as FS-USB_DEVICE (CDC), Debug via built in STLink
- OpenSTM32 IDE (Eclipse 4.6.3, OpenSTM32 IDE 2.3.0.201710251246, ARM Compiler for MCU 1.15.0.201708311556)
- CubeMX for HAL configuration (Version 4.22.0, STM32Cube V1.0)
- HAL Firmware STM32Cube_FW_F4_V1.16.0
- I2C works in blocking mode (no Interrupt, no DMA)
- I2C runs in Fast mode, external pull-ups
- UART runs at 9600-8-N-1in Interrupt mode (but error occurs even when the interrupt is turned off)
- Logic voltage levels for I2C and UART: 2.0V
Searching the forums here or the internet did not reveal a solution that solved my problem.
Any ideas or hints where to find additional information or what to check next?
What could (in general) happen that makes the HAL-UART block the I2C interface so that the I2C-busy-flags never resets?
Thanks in advance for any hint,
Thomas