cancel
Showing results for 
Search instead for 
Did you mean: 

STM32F0308-DISCOVERY I2C Init

vendor
Associate II
Posted on February 02, 2014 at 23:56

Please provide guidance: I am attempting to configure i2c on STM32F0308-Discovery 

Like to use PIN 46/47 as PF6/PF7 i2c1_SCL and i2c1_SDA

/* FROM DISCOVERY Driver 

Enable peripheral clock using RCC_APB1PeriphClockCmd(

RCC_APB1Periph_I2Cx

, ENABLE)

       function for I2C1 or I2C2.

   (♯) Enable SDA, SCL  and SMBA (when used) GPIO clocks using 

       RCC_AHBPeriphClockCmd() function. 

   (♯) Peripherals alternate function: 

       (++) Connect the pin to the desired peripherals' Alternate 

            Function (AF) using GPIO_PinAFConfig() function.

       (++) Configure the desired pin in alternate function by:

            GPIO_InitStruct->GPIO_Mode = GPIO_Mode_AF

       (++) Select the type, OpenDrain and speed via  

            GPIO_PuPd, GPIO_OType and GPIO_Speed members

       (++) Call GPIO_Init() function.

   (♯) Program the Mode, Timing , Own address, Ack and Acknowledged Address 

       using the I2C_Init() function.

*/

What is parameter to enter for RCC_AHBPeriphClockCmd(

??????

Definition of function from xxxRCC.c  (no definition in xxxRCC.h )

void RCC_AHBPeriphClockCmd(

uint32_t RCC_AHBPeriph

, FunctionalState NewState)

RCC_AHBPeriph is undefined in project for I2C .. 

 RCC_APB1PeriphClockCmd(

RCC_APB2Periph_I2C1

, ENABLE);

 RCC_AHBPeriphClockCmd(

RCC_APB2Periph_I2C1

, ENABLE);

I have not found a similar thread in searching.

I thank you in advance for assistance.

#i2c #stm32f32-discovery
1 REPLY 1
Posted on February 03, 2014 at 01:21

You'll perhaps want to review what's connected to the different buses AHB, APB1 and APB2

You' want to start with enabling the AHB clock for the pin bank you plan to use, before configuring the pins themselves.

  /* Enable GPIOFclock */

  RCC_AHBPeriphClockCmd(RCC_AHBPeriph_GPIOF, ENABLE);

Tips, Buy me a coffee, or three.. PayPal Venmo
Up vote any posts that you find helpful, it shows what's working..