Hello,
I am writing an i2c interface using the driver lib. In order to read the temperature of different "transistors" i need use the code from the driver lib:
uint16_t readData( struct I2CMsg *msg )
{
//
// Wait until the STP bit is cleared from any previous master
// communication.
if(I2C_getStopConditionStatus(I2CA_BASE))
{
return(ERROR_STOP_NOT_READY);
}
//
// Setup address of control of temp sensors
I2C_setSlaveAddress(I2CA_BASE, TMP_422_ADD);
// send address of register to read
// when this is ready, interrupt handles the read process
if(msg->msgStatus == MSG_STATUS_SEND_NOSTOP)
{
//
// Check if bus busy
if(I2C_isBusBusy(I2CA_BASE))
{
return(ERROR_BUS_BUSY);
}
//
// Send data to setup EEPROM address
I2C_setDataCount(I2CA_BASE, 1);
I2C_putData(I2CA_BASE, msg->pointer);
I2C_setConfig(I2CA_BASE, I2C_MASTER_SEND_MODE);
I2C_sendStartCondition(I2CA_BASE);
}
return(SUCCESS);
}
in the interrupt ISR:
i2cISR()
{
....
if(intSource == I2C_INTSRC_STOP_CONDITION)
    {
        //
        // If completed message was writing data, reset msg to inactive state
        if(currentMsgPtr->msgStatus == MSG_STATUS_WRITE_BUSY)
        {
            currentMsgPtr->msgStatus = MSG_STATUS_INACTIVE;
        }
        else
        {
            if(currentMsgPtr->msgStatus == MSG_STATUS_SEND_NOSTOP_BUSY)
            {
                currentMsgPtr->msgStatus = MSG_STATUS_SEND_NOSTOP;
            }
            //
            // If completed message read
            else if(currentMsgPtr->msgStatus == MSG_STATUS_READ_BUSY)
            {
                for(i=0; i < currentMsgPtr->numBytes; i++)
                {
                    currentMsgPtr->msgBuffer[i] = I2C_getData(I2CA_BASE);
                }
                // make possible to write message again
                currentMsgPtr->msgStatus = MSG_STATUS_SEND_NOSTOP;
            }
        }
    }
...
}
This works ok, if I time-out between sending the write condition:
write(sensorMsgs1)
timeout
write(sensoreMsg2)
timeout etc.
My idea was to :
void readPcBSensors( void )
{
    static pcbSelect selectedSensor = TEMP_1;
    if( I2C_isBusBusy(I2CA_BASE) )
    {
        switch( selectedSensor )
        {
            case TEMP_1:
                if( readPcbTemp1( ) == SUCCESS )
                {
                    selectedSensor = TEMP_2;
                }
                else
                {
                    NOP();
                }
                break;
            case TEMP_2:
 
......
    }
}
With:
uint16_t readPcbTempLoc( void )
{
    uint16_t error = 1;
    //
    // Check incoming message status
    if(i2cMsgInExTempLoc.msgStatus == MSG_STATUS_SEND_NOSTOP)
    {
        //
        // Send EEPROM address setup
        //
        currentMsgPtr = &i2cMsgInExTempLoc;
        error = readData( &i2cMsgInExTempLoc );
        //
        // Update current message pointer and message status if
        // read success else try again next time
        if( error == SUCCESS)
        {
            i2cMsgInExTempLoc.msgStatus = MSG_STATUS_SEND_NOSTOP_BUSY;
        }
        else
        {
            NOP;
        }
   }
   return error;
}
The Problem is, that i never get to writing data since:
if(I2C_isBusBusy(I2CA_BASE) is always true
What did i get wrong? If i remvove the condition:
if(I2C_isBusBusy(I2CA_BASE))
and time-out between the reads, it works, if i not time out, the program also gets stuck at
if(I2C_isBusBusy(I2CA_BASE)) in the readData function.
Thanks in advance.
 
				 
		 
					 
                          