2013-02-25 12:23 AM
Hi, does someone have experience with unable to clear STOPF bit, what causes continually jumps into i2c IRQ?
I am trying to do it this way:I2C_ClearFlag(I2C1,I2C_FLAG_STOPF);
,but it does not work.The reference manual says, the STOPF bit is:Cleared by software reading the SR1 register followed by a write in the CR1 register, or by hardware when PE=0.
The reading of SR1 works ok, but after writing to CR1 using: I2C_Cmd(I2C1, ENABLE); the STM pulls the SCL constantly LOW.Michal2013-02-25 05:23 AM
Please post a minimal but complete code exhibiting the problem.
JW2013-02-25 11:51 PM
Well, I try to describe situation.
Slave is STM32F407 discovery kit, which only transmitts data (should simulate some dummy sensor). Master is some another controller board, which sends commands in two parts: 1. Master sends SLAVE_ADDR + WRITE (''0'') - serves to wake-up sensor 2. Then wait 40ms. 3. Master sends SLAVE_ADDR + READ (''1'') and expect to return 4 Bytes from slave. The first part works well, slave sends ACK, and master can apply STOP condition.void I2C1_EV_IRQHandler(void) {
static
uint32_t index = 0;
uint32_t event = I2C_GetLastEvent(I2C1);
switch (event) {
case I2C_EVENT_SLAVE_RECEIVER_ADDRESS_MATCHED:
I2C_ReceiveData(I2C1);
break;
case I2C_EVENT_SLAVE_TRANSMITTER_ADDRESS_MATCHED:
I2C_SendData(I2C1, I2C_DATA[index++]);
break;
case I2C_EVENT_SLAVE_BYTE_TRANSMITTED:
I2C_SendData(I2C1, I2C_DATA[index++]);
break;
case I2C_EVENT_SLAVE_STOP_DETECTED:
index = 0;
I2C_Cmd(I2C1, ENABLE);
break;
default:
break;
}
}
2013-02-26 12:08 AM
I forgot to mention, first reading from slave is success, slave sends 4bytes. The communication is corrupt in second reading.
2013-03-04 01:34 AM
Please post a minimal but complete code exhibiting the problem.
JW2013-11-20 04:50 AM
2013-11-20 06:15 AM
Hi,I am working on project''Evaluation of a 3 axis accelerometer and gyroscope'' using STM32F407 and MPU6050.can someone you please tell me the code for interfacing these two using I2C bus and also hooking up connections....
2013-11-20 06:47 AM
<i>
can someone you please tell me the code for interfacing these two using I2C bus</i> a consultant can <i>also hooking up connections....</i> looking at your scope pictures it seems that smaller pull-up resistors might help. Erik2013-11-20 06:59 AM
You are off topic, start a new thread if your posting is irrelevant to the thread.
If you need someone to code your project, ST does maintain a list of contractors/consultants.http://www.st.com/web/en/support/mcu_design_consultants.html