2014-02-12 11:22 AM
My original post *poof* gone..
I am attempting to use I2C2, however Oscilliscope does not see any activity on either SCL or SDA. Using STM32F0308-Discovery. Obviously timing parameter is wrong, have tried many as I seem to be missing documentation, not sure that is only issue here. I have been wrestling with this issue for 2+ weeks and have exhausted all other options, Any assistance would be greatly appreciated. Note I am using GPIO PF6/PF7 as I2C2, as this part does not support I2C1 for these pins, I2C1 is unused. Both pins are high at power up with external pull up resistors. Have start delay of 50ms after reset and prior to initializing I2C2.void print7SegDisplay(void) { uint16_t i =0; uint16_t testdata = 0x7D; // Configures the slave address to be transmitted after start generation. I2C_SlaveAddressConfig(I2C2, 0x70); I2C_MasterRequestConfig(I2C2, I2C_Direction_Transmitter); I2C_GenerateSTART(I2C2, ENABLE); I2C_NumberOfBytesConfig(I2C2, 9); // number of bytes to send I2C_SendData(I2C2, 0x21); // turn on Oscillator I2C_SendData(I2C2, 0x81); // turn on Display for (i=0; i<8; i++) { I2C_SendData(I2C2, testdata); I2C_SendData(I2C2, testdata >> 8); } I2C_GenerateSTOP(I2C2, ENABLE); }void I2C_Configure(void){ // I2C2 Configuration STM32F0308-DISCOVERY on GPIO PF6 & PF7 // Note does not use I2C1 // RCC_APB1PeriphClockCmd(RCC_APB1Periph_I2C2, ENABLE); RCC_AHBPeriphClockCmd(RCC_AHBPeriph_GPIOF, ENABLE); GPIO_InitTypeDef GPIO_InitStructure; GPIO_InitStructure.GPIO_Pin = GPIO_Pin_6 ; //SCL GPIO_InitStructure.GPIO_Speed = GPIO_Speed_50MHz; GPIO_InitStructure.GPIO_Mode = GPIO_Mode_AF; GPIO_InitStructure.GPIO_OType = GPIO_OType_PP; GPIO_PinAFConfig(GPIOF, GPIO_PinSource6, GPIO_AF_1); GPIO_Init(GPIOF, &GPIO_InitStructure); GPIO_InitStructure.GPIO_Pin = GPIO_Pin_7 ; //SDA GPIO_InitStructure.GPIO_Speed = GPIO_Speed_50MHz; GPIO_InitStructure.GPIO_Mode = GPIO_Mode_AF; GPIO_InitStructure.GPIO_OType = GPIO_OType_OD; GPIO_PinAFConfig(GPIOF, GPIO_PinSource7, GPIO_AF_1); GPIO_Init(GPIOF, &GPIO_InitStructure); // I2C_InitTypeDef I2C_InitStructure; I2C_InitTypeDef I2C_InitStructure; I2C_InitStructure.I2C_Timing = 0x00; I2C_InitStructure.I2C_AnalogFilter = I2C_AnalogFilter_Disable; I2C_InitStructure.I2C_DigitalFilter = 0x00; I2C_InitStructure.I2C_Mode = I2C_Mode_I2C; I2C_InitStructure.I2C_OwnAddress1 = 0x00; I2C_InitStructure.I2C_Ack = I2C_Ack_Enable; I2C_InitStructure.I2C_AcknowledgedAddress = I2C_AcknowledgedAddress_7bit; I2C_Cmd(I2C2, ENABLE);//I2C Peripheral Enable I2C_Init(I2C2, &I2C_InitStructure);//Apply I2C configuration after enabling it } #stm32f03 #discovery #i2c2014-02-12 11:56 AM
GPIO_InitStructure.GPIO_OType = GPIO_OType_PP; // Definitely needs to be OD
Pretty sure you can't just jamb I2C functions one after another, you'd need to spin waiting for status/state changes, TXE, etc.2014-02-12 12:47 PM
Clive,
Again, thank you. I made change to OD, still no acitvity on either SDA or SCL. I am having trouble determining value for this statement:I2C_InitStructure.I2C_Timing = 0x00;
Pretty sure this is incorrect.. but cannot find any reference to the correct value other than a very cryptic '' uint32_t I2C_Timing; /*!< Specifies the I2C_TIMINGR_register value. This parameter must be set by referring to I2C_Timing_Config_Tool*/'' This appears to be missing from the toolset (and I have looked everywhere). In regards to the writing to the I2C, I know that is wrong, I just wanted to hit the I2C bus with some data looking for a heartbeat, or at least a single pulse of data. Just trying to properly initialize I2C2 for now. I thank you in advance for your assistance. Rick43065