Title: STM32F1, CubeMx I2C issue Post by: sam_des on October 15, 2016, 07:31:49 19:31 Hello,
Working on porting a project that was originally done using ST's StdPeriph Library to CubeMX HAL. Controller is STM32F103ZET6. One of the code involves a touch screen controller over I2C-1. Original code works fine, but cose generated by CubeMx does not. Initialization of I2C goes fine with CubeMx code, But after that any read or write locks the controller in infinite loop checking BUSY status flag. Specifying any value for TimeOut doesn't work. No other peripheral, internal or external is being used at the moment for testing I2C. Scope shows no activity at all on SCL/SDA lines. Also I am using latest CubeMx and CubeMxF1 packages. Any help will be great. Title: Re: STM32F1, CubeMx I2C issue Post by: sam_des on October 16, 2016, 09:16:32 09:16 Hello again,
Finally solved the issue... Here's what needs to be added to code from CubeMx to make it work... Code: void HAL_I2C_MspInit(I2C_HandleTypeDef* hi2c) Also, if you are also using FSMC, make sure you disable FSMC clock before accessing I2C &/or vice versa... Code: // Disable I2C clock & Enable FSMC clock Hope this helps others. Thanks. sam_des |