2006-05-01 02:05 AM
2006-04-21 12:57 AM
Hallo,
I am trying to get a ST0676 connected to a STR710 working. The first time I read for instance, the Version register of the ST0676 everything is ok, but on the second access the read bit in the address is always set. I use the STR7x Library and the following code: void I2cInit(I2C_TypeDef *I2Cx, int Clock) { I2C_Init(I2Cx); I2C_FCLKConfig (I2C0); I2C_OnOffConfig (I2C0, ENABLE); I2C_SpeedConfig (I2C0, Clock); I2C_AddressConfig (I2C0, 0x0C0, I2C_Mode7); I2C_AcknowledgeConfig (I2C0, ENABLE); } int I2cRead(I2C_TypeDef *I2Cx, int cmdLen, int readLen, unsigned char *bufp) { I2C_Tx_Status sendaddress,bSendResult; I2C_Rx_Status rxStatus; int i, I2CStatus; I2cInit(I2Cx, 4000); I2C_STARTGenerate(I2Cx, ENABLE); while(I2C_FlagStatus(I2Cx, DIRECT, I2C_SB ) == RESET); I2C_AddressSend(I2Cx, bufp[0], I2C_Mode7, I2C_TX); //Test on the status of transmission while(sendaddress != I2C_TX_ADD_OK) { sendaddress = I2C_TransmissionStatus(I2Cx); } while(I2C_FlagStatus(I2Cx, DIRECT, I2C_ENDAD) == RESET); I2C_FlagClear(I2Cx, I2C_ENDAD); for(i = 1; i < cmdLen; i++) { I2C_ByteSend(I2Cx, bufp[i]) ; //Test on the status of transmission while(bSendResult != I2C_TX_DATA_OK) { bSendResult = I2C_TransmissionStatus(I2Cx); } } //Stop the transmission I2C_STOPGenerate (I2Cx, ENABLE); // delay for the ST0676 ctl_timeout_wait(DELAY(10)); I2C_STARTGenerate(I2Cx, ENABLE); while(I2C_FlagStatus(I2Cx, DIRECT, I2C_SB ) == RESET); // send register address I2C_AddressSend(I2Cx, bufp[0], I2C_Mode7, I2C_RX); //Test on the status of transmission while(I2C_FlagStatus(I2Cx, DIRECT, I2C_ENDAD ) == RESET); I2C_FlagClear(I2Cx, I2C_ENDAD); for(rxStatus = 0, i = 0; i < readLen - 1; i++) { //Test on the status of transmission while(rxStatus != I2C_RX_DATA_OK) { rxStatus = I2C_ReceptionStatus(I2Cx); } // get the byte received bufp[i] = I2C_ByteReceive(I2Cx); } // receive last byte I2C_AcknowledgeConfig (I2C0, DISABLE); bufp[i] = I2C_ByteReceive(I2Cx); i++; //Stop the transmission I2C_STOPGenerate(I2Cx, ENABLE); I2C_OnOffConfig(I2Cx, DISABLE); return i; } I hope there is anybody who give me and idea what’s wrong. Regards, ctk2006-05-01 02:05 AM
Hi,
in the mean time i found the problem (or get close to). The ST0676 is very slow. To compensate this I have inserted several delays in the I2C read part. But the communication between the STR10 and the ST0676 is very unstable. The main Problem is a Arbitration Lost Error (in case of a write cmd) in the Status of the I2c-status register, which only should occur in a multi master environment, but the both devices are the only one on the bus. The bus is pulled up with 4k7 Resistors (I also tried other values with no different). Did you have any idea what the reason for this status (ARLO) is ? regards, ctk