1
votes

I'm trying to use the I2C interface of the STM32F3 Nucleo-Board to communicate with a EEPROM.

Unfortunately I don't have a clock signal. I tried to get a clock signal by setting the bits in the registers and also by using CubeMX. Both times I've got the same result: no clock signal.

Thanks for your help!

Here my code...

void I2C_Init(void){

RCC->AHBENR |= RCC_AHBENR_GPIOAEN;
RCC->AHBENR |= RCC_AHBENR_GPIOBEN;

GPIOA->MODER |= GPIO_MODER_MODER15_1; 
GPIOA->MODER &= ~GPIO_MODER_MODER15_0; //AF
GPIOB->MODER |= GPIO_MODER_MODER7_1; 
GPIOB->MODER &= ~GPIO_MODER_MODER7_0;  //AF

GPIOA->OTYPER |= GPIO_OTYPER_OT_15;
GPIOB->OTYPER |= GPIO_OTYPER_OT_7;    //Open drain

GPIOA->OSPEEDR |= (GPIO_OSPEEDER_OSPEEDR15_0 | GPIO_OSPEEDER_OSPEEDR15_1);  //speed high
GPIOB->OSPEEDR |= (GPIO_OSPEEDER_OSPEEDR7_0 | GPIO_OSPEEDER_OSPEEDR7_1);

GPIOA->PUPDR &= ~(GPIO_PUPDR_PUPDR15_0 | GPIO_PUPDR_PUPDR15_1);
GPIOB->PUPDR &= ~(GPIO_PUPDR_PUPDR7_0 | GPIO_PUPDR_PUPDR_1);  //no pull -> external pull up resistor used

PA15_AF4();
PB7_AF4();  //alternate function 4 used

RCC->CFGR3 |= (1<<I2C1SW);              //SYSCLK
RCC->APB1ENR |= RCC_APB1ENR_I2C1EN;     //clock enable

I2C1->TIMINGR = 0x10707DBC;  //with CubeMX

I2C1->CR1 |= I2C_CR1_PE;            //peripheral enable

}

I use PA15 for SCL and PB7 for SDA.

1
PA15_AF4() PB7_AF4() are magic and non standard. Please just use the HAL library. You already generated code using cubemx. Also what happens if you just use the default SDA and SCL GPIOs - Tarick Welling
Hope you don't expect the clock to be present without issuing any master request on the bus (as there is no code of any communication attempt) - KIIV
See comment of question author (Steffi) below the only answer: Apparently, the original question has not been fully analysed but in the end the problem was something different. Question seems obsolete now, and further clarification unlikely to come - I'm voting to close it. The uncompleted Q&A won't help other readers. - HelpingHand

1 Answers

0
votes

I2C will only generate a clock on the line if it is sending or expecting data. Try sending data and then using a scope to probe the data and clock line.