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?
I2C and timers?
I2C and 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.
-
- Posts: 633
- Joined: Thu Dec 19, 2019 1:23 am
Re: I2C and timers?
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
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
https://github.com/stm32duino/wiki/wiki ... nmap-array
Just build a spreadsheet with one column defining your need, another column the chip resource, and another column the pinouts.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.
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
-
- Posts: 502
- Joined: Fri Dec 27, 2019 4:53 pm
- Location: Munich, Germany
- Contact:
Re: I2C and timers?
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.
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.
Re: I2C and timers?
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
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
Re: I2C and 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.
Re: I2C and timers?
Thank you @fpiSTM , thant answers my question perfectly