STM32F100: UART1 and I2C2 simultaneously

ChibiOS public support forum for topics related to the STMicroelectronics STM32 family of micro-controllers.

Moderator: RoccoMarco

Post Reply
xobs
Posts: 3
Joined: Thu Aug 29, 2013 10:19 am

STM32F100: UART1 and I2C2 simultaneously

Post by xobs »

Hi,

I'm trying to use both UARTD1 and I2C2 on an STM32F101 (similar to an STM32F100). I have my board defined, and I'm getting debug text out the serial port. The serial port will be the primary means of communication with this device.

I noticed that when I initialize I2C2 before UARTD1, I'm able to see text on the serial port but I only get the I2C address emitted on the I2C bus. Weirdly, it looks like the I2C data is ending up on the serial port rather than getting sent.

If I initialize UARTD1 before I2C2, then I2C2 is able to send data but I get no serial text at all.

In my mcuconf.h I have I2C2 on DMA priority 3, and USART1 at priority 0.

I did notice that both UARTD1 and I2C2 are defined to have their TX and RX DMA stream IDs set as STM32_DMA_STREAM_ID(1,4) and STM32_DMA_STREAM_ID(1,5) respectively, but I'm not sure how to change that.

How can I use both UARTD1 and I2C2 at the same time?
xobs
Posts: 3
Joined: Thu Aug 29, 2013 10:19 am

Re: STM32F100: UART1 and I2C2 simultaneously

Post by xobs »

Answering my own reply. According to the reference manual, both devices share DMA channels 4 and 5. So the answer is: You don't use DMA.

So my options are either to use PIO or redesign the board.
User avatar
Giovanni
Site Admin
Posts: 14891
Joined: Wed May 27, 2009 8:48 am
Has thanked: 1202 times
Been thanked: 996 times

Re: STM32F100: UART1 and I2C2 simultaneously

Post by Giovanni »

You have two more options:

1) Use the Serial driver instead of the UART driver (SD1) which does not require a DMA.
2) Continue to use UARTD1 and I2CD2 but not at the same time (when one is started the other must be stopped, the DMAs are reallocated automatically on the fly).

Giovanni
Post Reply