Problem on STM32L1 with USART and I2C

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

Moderators: RoccoMarco, barthess

dflogeras
Posts: 212
Joined: Tue Sep 03, 2013 8:16 pm
Has thanked: 7 times
Been thanked: 19 times

Problem on STM32L1 with USART and I2C

Postby dflogeras » Sun Nov 10, 2013 2:58 pm

Hi,

I'm toying around with a STM32L1 discovery using ChibiOS 2.6.1. I currently have taken the UART example from testhal/STM32L1xx/ and have added I2C to it so that I can communicate with a I2C to 1wire chip that is wired up to my uC.

Everything was working fine while I used UART2 (TX/RX on pins PA2/3 respectively) and I2C2 (SCL SDA on pins PB10/PB11 respectively). Now I am laying out a board and geographically it makes more sense for me to use I2C1 on pins PB6/7. When I switch the I2C config and pins, neither the UART nor the I2C seems to work. I scoped the I2C bus and can see the signals twiddle as it sends the device ID but my I2C to 1wire chip never responds. Likewise, I don't seem to receive any charactersr on the UART2. If I simply comment out the UART related code, the I2C1 communicates as expected.

Next, if I switch to using USART1 (TX/RX on pins PA9/10) the USART1 and I2C1 both seems to work.

I checked the datasheet/manuals for the STM32L15x and can't see any reasons for this (although I am quite new to these devices). Can anyone offer any help in troubleshooting this?

So to summarize:

Works:
I2C2 on PB10/11 with USART2 on PA2/3
I2C1 on PB8/9 with USART1 on PA9/10

Not working:
I2C1 on PB8/9 with USART2 on PA2/3 (commenting out the USART makes I2C work again)

Thanks,
Dave

User avatar
Giovanni
Site Admin
Posts: 14455
Joined: Wed May 27, 2009 8:48 am
Location: Salerno, Italy
Has thanked: 1076 times
Been thanked: 922 times
Contact:

Re: Problem on STM32L1 with USART and I2C

Postby Giovanni » Sun Nov 10, 2013 3:01 pm

Hi,

Check for DMA conflicts on the reference manual.

Giovanni

dflogeras
Posts: 212
Joined: Tue Sep 03, 2013 8:16 pm
Has thanked: 7 times
Been thanked: 19 times

Re: Problem on STM32L1 with USART and I2C

Postby dflogeras » Sun Nov 10, 2013 4:23 pm

Giovanni,

Of course you are right! UART1 and I2C2 share DMA channels, as do UART2 and I2C1. In case this helps anyone else (or future me, searching the forum), reference Table 41 "Summary of DMA1 requests for each channel" in RM0038.

Thanks!

dflogeras
Posts: 212
Joined: Tue Sep 03, 2013 8:16 pm
Has thanked: 7 times
Been thanked: 19 times

Re: Problem on STM32L1 with USART and I2C

Postby dflogeras » Sun Nov 10, 2013 4:26 pm

I guess to follow that up, is it not possible to share DMA channels? For instance if I needed to use 2 UARTs and 2 I2Cs.

User avatar
Giovanni
Site Admin
Posts: 14455
Joined: Wed May 27, 2009 8:48 am
Location: Salerno, Italy
Has thanked: 1076 times
Been thanked: 922 times
Contact:

Re: Problem on STM32L1 with USART and I2C

Postby Giovanni » Sun Nov 10, 2013 4:50 pm

You can, start one driver at time.

Giovanni


Return to “STM32 Support”

Who is online

Users browsing this forum: No registered users and 14 guests