Hallo Community
Bei meiner Eeprom Routine ( adaptiert aus den Examples ) liegt ewig das
I2C Busy Flag an und die Kommunikation erzeugt ein Timeout. Hier erstmal
der Sourcecode:
void sEE_LowLevel_Init(void)
{
GPIO_InitTypeDef GPIO_InitStructure;
NVIC_InitTypeDef NVIC_InitStructure;
/*!< sEE_I2C_SCL_GPIO_CLK and sEE_I2C_SDA_GPIO_CLK Periph clock enable
*/
RCC_APB2PeriphClockCmd(sEE_I2C_SCL_GPIO_CLK | sEE_I2C_SDA_GPIO_CLK,
ENABLE);
/*!< sEE_I2C Periph clock enable */
RCC_APB1PeriphClockCmd(sEE_I2C_CLK, ENABLE);
/*!< GPIO configuration */
/*!< Configure sEE_I2C pins: SCL */
GPIO_InitStructure.GPIO_Pin = sEE_I2C_SCL_PIN;
GPIO_InitStructure.GPIO_Speed = GPIO_Speed_50MHz;
GPIO_InitStructure.GPIO_Mode = GPIO_Mode_AF_OD;
GPIO_Init(sEE_I2C_SCL_GPIO_PORT, &GPIO_InitStructure);
/*!< Configure sEE_I2C pins: SDA */
GPIO_InitStructure.GPIO_Pin = sEE_I2C_SDA_PIN;
GPIO_Init(sEE_I2C_SDA_GPIO_PORT, &GPIO_InitStructure);
}
void sEE_Init(void)
{
I2C_InitTypeDef I2C_InitStructure;
sEE_LowLevel_Init();
/*!< I2C configuration */
/* sEE_I2C configuration */
I2C_InitStructure.I2C_Mode = I2C_Mode_I2C;
I2C_InitStructure.I2C_DutyCycle = I2C_DutyCycle_2;
I2C_InitStructure.I2C_OwnAddress1 = I2C_SLAVE_ADDRESS7;
I2C_InitStructure.I2C_Ack = I2C_Ack_Enable;
I2C_InitStructure.I2C_AcknowledgedAddress =
I2C_AcknowledgedAddress_7bit;
I2C_InitStructure.I2C_ClockSpeed = I2C_SPEED;
/* sEE_I2C Peripheral Enable */
I2C_Cmd(sEE_I2C, ENABLE);
/* Apply sEE_I2C configuration after enabling it */
I2C_Init(sEE_I2C, &I2C_InitStructure);
/* Enable the sEE_I2C peripheral DMA requests */
I2C_DMACmd(sEE_I2C, ENABLE);
/*!< Select the EEPROM address */
sEEAddress = sEE_HW_ADDRESS;
}
uint32_t sEE_ReadBuffer(uint8_t* pBuffer, uint16_t ReadAddr, uint16_t*
NumByteToRead)
{
/* Set the pointer to the Number of data to be read. This pointer will
be used
by the DMA Transfer Completer interrupt Handler in order to reset
the
variable to 0. User should check on this variable in order to know
if the
DMA transfer has been complete or not. */
sEEDataReadPointer = NumByteToRead;
/*!< While the bus is busy */
sEETimeout = sEE_LONG_TIMEOUT;
while(I2C_GetFlagStatus(sEE_I2C, I2C_FLAG_BUSY))
{
if((sEETimeout--) == 0) return 11;
//sEE_TIMEOUT_UserCallback();
}
In der While Schleife hat er sein timeout. Ich kann die Var sEETimeout
so hoch wie ich will einstellen der Bus wird niemals frei.
Mit dem Oszilloskop hab ich es geprüft. Da ist nixs auf den
Signalleitungen.
Wie kommt es zu diesem Problem kann mir jmd helfen ?
mfg Jan
Hallo Jan, ich glaub du kämpfst grad mit dem selben Problem wie ich: Beitrag "[STM32] I2C - Master Mode(Polling)" Warum I2C auf dem STM32 so zickig ist, weiß ich selbst nicht - die anderen Peripheriemodule funktionieren bei ja einwandfrei... Vielleicht kommen wir ja gemeinsam auf eine Lösung.
Also wenn ich richtig gelesen habe bist du ja schon soweit das er die Slave Adresse net akzeptiert. Mein Fehler, dass er den Bus net freigibt taucht ja schon eher auf. mfg Jan
Stimmt, aber zudem ist bei mir ebenfalls das Busy Flag andauernd gesetzt. Vielleicht kommt aus dem Grund kein ACK an?!
Für alle interessierten Es lag an einer fehlerhaften Verbindung des Pullup Widerstands.
Bitte melde dich an um einen Beitrag zu schreiben. Anmeldung ist kostenlos und dauert nur eine Minute.
Bestehender Account
Schon ein Account bei Google/GoogleMail? Keine Anmeldung erforderlich!
Mit Google-Account einloggen
Mit Google-Account einloggen
Noch kein Account? Hier anmelden.