cancel
Showing results for 
Search instead for 
Did you mean: 

Hello. Tell me why not work I2C2 in STM32F407Z if selection PF0 & PF1 pins. In initialization all ok, when choosing PB10 & PB11 all work. The following code works with pins PB10 & PB11. Thanks.

Oleg1
Associate II
GPIO_InitTypeDef G;
I2C_InitTypeDef I;
 
RCC_APB1PeriphClockCmd(RCC_APB1Periph_I2C2, ENABLE);
RCC_AHB1PeriphClockCmd(RCC_AHB1Periph_GPIOF, ENABLE);  
 
G.GPIO_Pin = (GPIO_Pin_0 | GPIO_Pin_1);
G.GPIO_OType = GPIO_OType_OD;
G.GPIO_PuPd = GPIO_PuPd_UP;
G.GPIO_Speed = GPIO_Speed_100MHz;
G.GPIO_Mode = GPIO_Mode_AF; 
GPIO_Init(GPIOF, &G);	
 
GPIO_PinAFConfig(GPIOF, GPIO_PinSource0, GPIO_AF_I2C2);
GPIO_PinAFConfig(GPIOF, GPIO_PinSource1, GPIO_AF_I2C2); 
 
I2C_DeInit(I2C2);
I.I2C_Ack = I2C_Ack_Enable;
I.I2C_OwnAddress1 = 0x01;
I.I2C_Mode = I2C_Mode_I2C;
I.I2C_DutyCycle = I2C_DutyCycle_2;
I.I2C_Ack = I2C_Ack_Enable;
I.I2C_AcknowledgedAddress = I2C_AcknowledgedAddress_7bit;
I.I2C_ClockSpeed = 400000; 
I2C_Init(I2C2, &I);
I2C_Cmd(I2C2, ENABLE);
I2C_AcknowledgeConfig(I2C2, ENABLE);

5 REPLIES 5
T J
Lead

PF0 and PF1 are which major function ?

is that the Crystal input pins ?

did you disable the Oscillator ?

are you using the cube or hand coded ?

Oleg1
Associate II

Crystal 32.768 connected to PC14-PC15 (pin 8-9)

Crystal 8 Mhz connected to PH0-PH1 (pin 23-24)

chip - STM32F407ZET6

Read out and check the content of respective GPIO registers.

JW

Oleg1
Associate II

Checked PF0 & PF1 in mode GPIO_IN + GPIO_PuPd_UP, when reading I get 1 & 2 if PF0 or PF1 connect to GND the signal changes to 0

Port inputs not involved in the scheme

I mean, after executing the code above, check whether PF0 and PF1 are set to AF in MODER and appropriate AF in AFRL as expected.

JW