- This topic has 2 replies, 1 voice, and was last updated 6 years, 11 months ago by .
Viewing 3 posts - 1 through 3 (of 3 total)
Viewing 3 posts - 1 through 3 (of 3 total)
- You must be logged in to reply to this topic.
Home › Forums › Mastering STM32 book support forum › I2C - No data transfer
Tagged: I2C
Hi,
I2C peripheral has been initialize with STM32CubeMX. I am using I2C1, pins B9 (data) and B8 (clock). The device ‘s address is 0x60. For starter, I can neither read nor write to the device. I’ve tried the two following ways:
1)
uint8_t outputData = 0;
HAL_I2C_Mem_Read(&hi2c1, 0x60, 0x0A, I2C_MEMADD_SIZE_8BIT, &outputData, 1, HAL_MAX_DELAY);
2)
uint8_t outputData = 0;
HAL_StatusTypeDef returnValue = 0;
returnValue = HAL_I2C_Master_Transmit(&hi2c1, 0x60, (uint8_t*)0x0A, 1, HAL_MAX_DELAY);
if(returnValue != HAL_OK) return returnValue;
returnValue = HAL_I2C_Master_Receive(&hi2c1, 0x60, &outputData, 1, HAL_MAX_DELAY);
These functions always falls in the following “if” block:
/* Send Slave Address and Memory Address */
if(I2C_RequestMemoryRead(hi2c, DevAddress, MemAddress, MemAddSize, Timeout, tickstart) != HAL_OK)
{
if(hi2c->ErrorCode == HAL_I2C_ERROR_AF)
{
/* Process Unlocked */
__HAL_UNLOCK(hi2c);
return HAL_ERROR;
}
The next image shows the activity in the bus.
I also tried with an EEPROM (mine is a 24LC02B – I/P – 2Kbits) following the exact code on the book, without success.
Please, help me to find a solution for this problem.
PS: I am using STM32F4-Discovery
I found the problem. The device I am using, a camera module OV9655, requires an input clock. I was using MCO1, with PLLCLK/4. When I checked the signal I saw that the output looked more like noise than an actual clock. Then, I changed it to output the clock from HSI and it worked.