enabling i2c2 on PB10 and PB11

Post here first, or if you can't find a relevant section!
Post Reply
aster
Posts: 100
Joined: Thu Mar 30, 2017 2:41 pm
Location: bella italy
Contact:

enabling i2c2 on PB10 and PB11

Post by aster » Sat Sep 02, 2017 8:37 pm

hello,

i have a problem with the AFIO, i would like to remap PB10 and PB11 to be iic2 instead of serial3, it should be connected to TIM2
i check a few topic and i found only info on how to activate the alternate function fo the spi1

this one i guess was for HAL or libmaple

Code: Select all

RCC_BASE->APB2ENR |= (uint32_t)RCC_APB2ENR_AFIOEN; // enable AFIO clock
delay(1); // maybe not needed
AFIO_BASE->MAPR = (uint32_t)(AFIO_MAPR_SPI1_REMAP | AFIO_DEBUG_NONE); // set AFIO register
or this one which come from roger's repo

Code: Select all

afio_cfg_debug_ports(AFIO_DEBUG_SW_ONLY); // release PB3 and PB5
afio_remap(AFIO_REMAP_SPI1); // remap SPI1
so, from system\libmaple\stm32f1\include\series\gpio.h i found:
AFIO_REMAP_USART3_PARTIAL = AFIO_MAPR_USART3_REMAP_PARTIAL,

what does this partial means? how could i activate the i2c2 from it?

zmemw16
Posts: 1418
Joined: Wed Jul 08, 2015 2:09 pm
Location: St Annes, Lancs,UK

Re: enabling i2c2 on PB10 and PB11

Post by zmemw16 » Sun Sep 03, 2017 12:33 am

assuming you can run cubemx and it's a blue pill 103c8, i've attached an ioc which should generate the correct info for you
full source tree bar the lib files is 180k
stephen
Attachments
bp-i2c2-ioc.txt
(3.59 KiB) Downloaded 31 times

aster
Posts: 100
Joined: Thu Mar 30, 2017 2:41 pm
Location: bella italy
Contact:

Re: enabling i2c2 on PB10 and PB11

Post by aster » Tue Sep 05, 2017 10:20 pm

thank you very much Stephen :D
i never used cubemx your ioc will be very helpfull!

zmemw16
Posts: 1418
Joined: Wed Jul 08, 2015 2:09 pm
Location: St Annes, Lancs,UK

Re: enabling i2c2 on PB10 and PB11

Post by zmemw16 » Wed Sep 06, 2017 8:46 pm

it's quite good fun as well.

still trying to see how retaining user code works.

on the Black F407ZG it seems that the BL back light pin is connected to PB6, so i've to move I2C1 to PB10/PB11 and waggle PB6 from a timer as well . so as i said, fun.

stephen

Post Reply