I2C and timers?

Post here first, or if you can't find a relevant section!
Post Reply
GVisser
Posts: 19
Joined: Thu Jun 11, 2020 5:17 pm
Answers: 1
Location: Hatfield, UK

I2C and timers?

Post by GVisser »

Hi all,

Another NOOB question :-)

I am trying to plan my pin usage for my project with future additions in mind so am trying to understand what resources I2C requires.

I am using my STM32F401CCU6 Black Pill which seems to have 3 I2C ports.

As I am using a number of encoders and have a PWM output, I want to make sure that I leave myself open to adding an I2C interfaced LCD or OLED display later.

So the question is: Does I2C use the timers associated with the specific pins?
ie. If I select to use the second I2C interface:
on PB3 - SDA2 is associated with Timer2 Chan2
on PB10 - SCL2 is associated with Timer2Chan3
This would lead me to believe that I should not use Timer 2 for any other purpose? (PWM and/or encoders)

Then in the case of the 3rd I2C:
SDA3 is on Tim3Ch1
SCL3 is on Tim1Ch1
This is split over 2 timers???

Do I need to take the SMBA channels/timers into account?
PB12 - SMBA2 is on Tim1_BKIN

PS. The only reason I have not mentioned the first I2C interface is because I have used Timer4 for 2 of my encoders. As I am already using all of my ADC pins, the only other place I could put these encoders would be on Timer 1, but am not clear on how wise this would be? ie. Is there anything special about the advanced control timer that would give me pause on using it for reading my encoders?
by fpiSTM » Mon Jun 22, 2020 8:42 am
GVisser wrote: Fri Jun 19, 2020 9:55 am
Then in the case of the 3rd I2C:
SDA3 is on Tim3Ch1
SCL3 is on Tim1Ch1
This is split over 2 timers???
There is no link btw I2C and timer. What you are looking for is the Alternate functions.
MCU has several peripherals (I2C, SPI, U(S)ART, TIMER, ...) and those peripherals can be linked to a specific GPIO.

You can have a look to this presentation (for G0 but same for all STM32 except F1)
https://www.stmicroelectronics.com.cn/c ... e-GPIO.pdf

mainly slide 6 on Alternate functions.
Go to full post
mrburnette
Posts: 633
Joined: Thu Dec 19, 2019 1:23 am
Answers: 7

Re: I2C and timers?

Post by mrburnette »

As you are using the STM Official core, you would be well served referencing the resource allocation of external requirements:

https://github.com/stm32duino/wiki/wiki ... nmap-array
Each variant provides a PeripheralPins.c including all PinMap arrays per STM32 peripherals: ADC, I2C, SPI, TIM, U(S)ART, USB,...
Each array provides a default mapping for which peripheral instance is used for a pin.
Just build a spreadsheet with one column defining your need, another column the chip resource, and another column the pinouts.

You may well wish to use the Maple Mini board and Roger's core as a template and create a spreadsheet for your specific board.

STM32DUNIO - Roger's Core & Maple Mini

Master Pin Map
stevestrong
Posts: 502
Joined: Fri Dec 27, 2019 4:53 pm
Answers: 8
Location: Munich, Germany
Contact:

Re: I2C and timers?

Post by stevestrong »

The F4 family has a pretty versatile pin mapping which allows you to select the alternative functions for the dedicated pins in an easy way.
Check the pin mapping of the corresponding 401CCU chip in the data sheet for the needed function, and then you can realize which function usage is possible on which pin.
GVisser
Posts: 19
Joined: Thu Jun 11, 2020 5:17 pm
Answers: 1
Location: Hatfield, UK

Re: I2C and timers?

Post by GVisser »

Hi @mrburnette and @stevestrong ,

Thank you for your replies.

I don't think I asked my question very well ... what I was actually asking was wether or not the I2C interfaces, made use of either the General Purpose or Advanced Control Timers?

I think that the answer is that they do not, but wanted to be sure.

Regards
Grant
User avatar
fpiSTM
Posts: 1754
Joined: Wed Dec 11, 2019 7:11 pm
Answers: 91
Location: Le Mans
Contact:

Re: I2C and timers?

Post by fpiSTM »

GVisser wrote: Fri Jun 19, 2020 9:55 am
Then in the case of the 3rd I2C:
SDA3 is on Tim3Ch1
SCL3 is on Tim1Ch1
This is split over 2 timers???
There is no link btw I2C and timer. What you are looking for is the Alternate functions.
MCU has several peripherals (I2C, SPI, U(S)ART, TIMER, ...) and those peripherals can be linked to a specific GPIO.

You can have a look to this presentation (for G0 but same for all STM32 except F1)
https://www.stmicroelectronics.com.cn/c ... e-GPIO.pdf

mainly slide 6 on Alternate functions.
GVisser
Posts: 19
Joined: Thu Jun 11, 2020 5:17 pm
Answers: 1
Location: Hatfield, UK

Re: I2C and timers?

Post by GVisser »

Thank you @fpiSTM , thant answers my question perfectly :D
Post Reply

Return to “General discussion”