2010-05-08 07:32 AM
STM32F103x8 i2c2 smaple code
2011-05-17 04:50 AM
code for I2C2 is exactly the same as I2C1, absolutely no difference (just replace I2C1 by I2C2).
But may be you have a hardware issue: - Are you using an ST Eval board ? - Are you sure no other IP is using the I2C2 pins ? and that a correct pull up resistors are connected to I2C2 pins? - If you wanna a simple demonstration code try the ST provided I2C examples (@ http://www.st.com/stonline/products/support/micro/files/stm32f10x_stdperiph_lib.zip then go to folder ''STM32F10x_StdPeriph_Lib_V3.3.0\Project\STM32F10x_StdPeriph_Examples\I2C\Interrupt'') - For GPIO configuration (from ST provided examples): GPIO_InitTypeDef GPIO_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); /* Configure I2C2 pins: SCL and SDA ----------------------------------------*/ GPIO_InitStructure.GPIO_Pin = GPIO_Pin_10 | GPIO_Pin_11; GPIO_Init(GPIOB, &GPIO_InitStructure); Is this the kind of information you are looking for ?2011-05-17 04:50 AM
DMA and interrupt handling is also different.
2011-05-17 04:50 AM
2011-05-17 04:50 AM
2011-05-17 04:50 AM
Hi again,
When you write to an EEPROM, in some cases, no error status is returned even when write operation is incorrect. So the read operation is the most critical. Your problem seems to be too ''large'', but I think it is probably still a HW issue. I think the main questions are: - Are you sure about the used EEPROM address ? - Are you sure about the pullups on I2C2 pins ? are there any other component using the same pins as I2C2 on your board? - Are you using the same I2C speed for both I2Cs? - Do you power off the EEPROM between the use of I2C1 and I2C2? - Are you using a separate EEPROM for each I2C? and in this case, are the two EEPROM identical (type, speed, address, ...). I hope these questions may help you investigate the issue :)2011-05-17 04:50 AM