cancel
Showing results for 
Search instead for 
Did you mean: 

I2C Not working with STM32F0 and Standard Peripheral Library

RAshworth
Associate II

I can't seem to get anything out of my I2C port. The is the first time I've done it using the standard peripheral library. I seem to get about 2clks at the start when monitoring it with an oscilloscope, then nothing. It is as if there is a peripheral clock I haven't turned on or something...?

Enclosed is initialisation code etc.

#defines etc:

//I2C Pin Configuration
#define I2C1_CLK RCC_APB1Periph_I2C1
 
#define I2C1_SDA_PIN               GPIO_Pin_7
#define I2C1_GPIO_SDA_PORT         GPIOB
#define I2C1_GPIO_SDA_CLK          RCC_AHBPeriph_GPIOB
#define I2C1_SDA_SOURCE            GPIO_PinSource7
#define I2C1_SDA_AF                GPIO_AF_1
 
#define I2C1_SCL_PIN               GPIO_Pin_6
#define I2C1_GPIO_SCL_PORT         GPIOB
#define I2C1_GPIO_SCL_CLK          RCC_AHBPeriph_GPIOB
#define I2C1_SCL_SOURCE            GPIO_PinSource6
#define I2C1_SCL_AF                GPIO_AF_1

//INITIALIZE THE IO FOR THE DAC
void DAC_IO_INIT()
{
	I2C_InitTypeDef  I2C_InitStructure;
	GPIO_InitTypeDef  GPIO_InitStructure;
 
	//Low Level Initialization:
 
	/* AD5693_I2C_SCL_GPIO_CLK, AD5693_I2C_SDA_GPIO_CLK */
	RCC_AHBPeriphClockCmd(I2C1_GPIO_SDA_CLK | I2C1_GPIO_SCL_CLK, ENABLE);
 
	/* AD5693_I2C Periph clock enable */
	RCC_APB1PeriphClockCmd(I2C1_CLK, ENABLE);
 
	/* Configure the I2C clock source. The clock is derived from the HSI */
	RCC_I2CCLKConfig(RCC_I2C1CLK_HSI);
 
	/* Connect PXx to I2C_SCL */
	GPIO_PinAFConfig(I2C1_GPIO_SCL_PORT, I2C1_SCL_SOURCE, I2C1_SCL_AF);
 
	/* Connect PXx to I2C_SDA */
	GPIO_PinAFConfig(I2C1_GPIO_SDA_PORT, I2C1_SDA_SOURCE, I2C1_SDA_AF);
 
	/* Configure AD5693  I2C pins: SCL */
	GPIO_InitStructure.GPIO_Pin = I2C1_SCL_PIN;
	GPIO_InitStructure.GPIO_Mode = GPIO_Mode_AF;
	GPIO_InitStructure.GPIO_Speed = GPIO_Speed_2MHz;
	GPIO_InitStructure.GPIO_OType = GPIO_OType_OD;
	GPIO_InitStructure.GPIO_PuPd  = GPIO_PuPd_UP;//NOPULL
	GPIO_Init(I2C1_GPIO_SCL_PORT, &GPIO_InitStructure);
 
	/* Configure AD5693_I2C pins: SDA */
	GPIO_InitStructure.GPIO_Pin = I2C1_SDA_PIN;
	GPIO_Init(I2C1_GPIO_SDA_PORT, &GPIO_InitStructure);
 
	/* AD5693_I2C configuration */
	I2C_InitStructure.I2C_Mode = I2C_Mode_I2C;
	I2C_InitStructure.I2C_AnalogFilter = I2C_AnalogFilter_Enable;
	I2C_InitStructure.I2C_DigitalFilter = 0x00;
	I2C_InitStructure.I2C_OwnAddress1 = 0x00;
	I2C_InitStructure.I2C_Ack = I2C_Ack_Enable;//Master - Single byte at a time
	I2C_InitStructure.I2C_AcknowledgedAddress = I2C_AcknowledgedAddress_7bit;
	I2C_InitStructure.I2C_Timing = AD5693_I2C_TIMING;
 
	/* Apply AD5693_I2C configuration after enabling it */
	I2C_Init(AD5693_I2C, &I2C_InitStructure);
 
	/* AD5693_I2C Peripheral Enable */
	I2C_Cmd(AD5693_I2C, ENABLE);

and

0 REPLIES 0