2018-11-03 01:19 PM
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);
2018-11-03 01:55 PM
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 ?
2018-11-03 03:42 PM
Crystal 32.768 connected to PC14-PC15 (pin 8-9)
Crystal 8 Mhz connected to PH0-PH1 (pin 23-24)
chip - STM32F407ZET6
2018-11-03 03:49 PM
Read out and check the content of respective GPIO registers.
JW
2018-11-03 04:09 PM
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
2018-11-04 01:03 AM
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