Using STR912
Using the I2C module in debug mode step by step it works fine, I can read and write properly, if I do exacly the same but in run time ... doesn't work anymore. Is it a frequency issue? This is my code for the initialization and clock settings:
Initialization of the module:
// I2C Module initialization OutputEnable(); //I2C0 reset I2C_DeInit(I2C0); // Enable I2C0 I2C_Cmd(I2C0, ENABLE); // I2C0 Configuration I2C_Struct.I2C_GeneralCall = I2C_GeneralCall_Disable; I2C_Struct.I2C_Ack = I2C_Ack_Enable; I2C_Struct.I2C_CLKSpeed = 100000; I2C_Struct.I2C_OwnAddress = 0x00; I2C_Init(I2C0, &I2C_Struct);
My general clock definition:
SCU_MCLKSourceConfig(SCU_MCLK_OSC); // Default configuration, wait state insertion :This function should be executed from SRAM when //booting from bank1 to avoid Read-While-Write from the Same Bank. FMI_Config(FMI_READ_WAIT_STATE_2, FMI_WRITE_WAIT_STATE_0, FMI_PWD_ENABLE,\ FMI_LVD_ENABLE, FMI_FREQ_HIGH);// Insert 2 Wait States for read SCU_PLLFactorsConfig(192, 25, 2); // PLL factors Configuration based on // a OSC/Crystal value = 25Mhz SCU_PLLCmd(ENABLE); // PLL Enable and wait for Locking SCU_RCLKDivisorConfig(SCU_RCLK_Div1); // RCLK @96Mhz SCU_HCLKDivisorConfig(SCU_HCLK_Div1); // AHB @96Mhz SCU_FMICLKDivisorConfig(SCU_FMICLK_Div1);// FMI @96Mhz SCU_PCLKDivisorConfig(SCU_PCLK_Div2); //APB @48Mhz SCU_MCLKSourceConfig(SCU_MCLK_PLL); //MCLK @96Mhz // working configuration @ 96 Mhz