Hello all,
I want to connect a sensor to I2C on the extension board of the Primer2.
I added following to the stm32f10x_conf.h file:
#define _I2C
#define _I2C1
#define _I2C2
then to the MENU_code Application_Ini I added:
#define I2C1_SLAVE_ADDRESS7 0xA0
GPIO_InitTypeDef GPIO_InitStructure;
I2C_InitTypeDef I2C_InitStructure;
/* Configure I2C1 pins: SCL and SDA */
GPIO_InitStructure.GPIO_Pin = GPIO_Pin_6 | GPIO_Pin_7;
GPIO_InitStructure.GPIO_Speed = GPIO_Speed_50MHz;
GPIO_InitStructure.GPIO_Mode = GPIO_Mode_AF_OD;
GPIO_Init(GPIOB, &GPIO_InitStructure);
/* I2C configuration */
I2C_InitStructure.I2C_Mode = I2C_Mode_I2C;
I2C_InitStructure.I2C_DutyCycle = I2C_DutyCycle_2;
I2C_InitStructure.I2C_OwnAddress1 = I2C1_SLAVE_ADDRESS7;
I2C_InitStructure.I2C_Ack = I2C_Ack_Enable;
I2C_InitStructure.I2C_AcknowledgedAddress = I2C_AcknowledgedAddress_7bit;
I2C_InitStructure.I2C_ClockSpeed = I2C_Speed;
/* I2C Peripheral Enable */
I2C_Cmd(I2C1, ENABLE);
/* Apply I2C configuration after enabling it */
I2C_Init(I2C1, &I2C_InitStructure);
In the code I add
I2C_GenerateSTART(I2C1, ENABLE);
/* Test on EV5 and clear it */
while(!I2C_CheckEvent(I2C1, I2C_EVENT_MASTER_MODE_SELECT));
/* Send EEPROM address for write */
I2C_Send7bitAddress(I2C1, I2C_MS5607_ADDRESS, I2C_Direction_Transmitter);
Basically it is the same as the example provided by ST. When I run it I do not see anything happening on SDA and SCL ports. I also ran it in debug mode and I do not see that I2C1 is on and well defined.
My questions are:
1. Where I am wrong?
2. What does this represent I2C_InitStructure.I2C_OwnAddress1 = I2C1_SLAVE_ADDRESS7; ? I used a lot Atmel and Microchip microcontrollers but this I never saw?
Thank you in advance,
Pred