Jump to content
43oh

I2C Slave - Burst Mode - LM3S2965


Recommended Posts

This is what i can think of :



 

/// SLAVE mode
if ( I2CSlaveIntStatus ( baseS , true ) )
{
..
..
..
..

/// SLAVE transmitter
if ( status == I2C_SLAVE_ACT_TREQ ) // Master has requested data
{
I2CSlaveDataTx(baseS);
}
}

void I2C_SlaveDataTx(uint32 baseS)
{
for(unsigned char tmp_var1 = 0; tmp_var1 < Max_I2C_Tx_Size; )
{
if((I2CSCSR & (1 << TREQ)))
{
I2CSlaveDataPut ( baseS , DATA_BUFFER[tmp_var1] );
tmp_var1++;
}
}
}
Link to post
Share on other sites

The code that i wrote in my previous post will be a Blocking code, so i wrote this :

This Routine will be Interrupt based.
When Ever there is a TREQ interrupt this routine should be executed.
 


#define Max_I2C_Tx_Size 13 // Maximum Number of Bbytes to be transmitted

#define TRUE 1
#define FALSE 0

unsigned char Data_Encode_OTFlag = TRUE; // One time Flag
unsigned char Data_Count_var = 0;

void ISR_I2C1_SlaveDataTx(void)
{
    DATAIC |= (1 << DATAIC); // Clear I2C TREQ/RREQ Interrupt
    
    if(Data_Encode_OTFlag)
    {
        Data_Encode_OTFlag = FALSE; // One Time Flag
        Data_Encode(); // Encodes individual data to 13 Byte Buffer
    }
    
    if(Data_Count_var < Max_I2C_Tx_Size) // Max_I2C_Tx_Size is the Maximum number of Bytes to be Sent
    {
        I2CSlaveDataPut ( baseS , DATA_BUFFER[tmp_var1] ); // Transmits one BYTE
        tmp_var1++; // Increments for the next Byte
        
        if(tmp_var1 >= Max_I2C_Tx_Size) // If all the 13 Bytes are sent
        {
            Data_Encode_OTFlag = TRUE; // Set the One Time Flag for the Next time
        }
    }
}

 



THE PROBLEM:
I don’t see a way to call this routine when the interrupt occurs

So far i was adding the Routine Name to the "startup_ccs.c" file, but i dont see the TREQ/RREQ interrput (according to datasheet it should be DATAIM bit in the I2C Slave Interrupt Mask (I2CSIMR) register.

Link to post
Share on other sites

The 'I2CHandler' is registered in the 'startup_ccs.c'.

I just wondered if there are individual interrupt routines that can be called, but there seems to be only 2 Interrupt handlers in the ' 'startup_ccs.c' files one for I2C0 and other for I2C1. (in AVR we have individual ISR's available so i thought there might be similar)



 

void I2CHandler ( uint8 index )
{
..
..
..

/// SLAVE transmitter
if ( status == I2C_SLAVE_ACT_TREQ ) // Master has requested data
{
ISR_I2C_SlaveDataTx(baseS);
}
}

void ISR_I2C_SlaveDataTx(uint32 baseS)
{
I2CSICR |= (1 << DATAIC); // Clear I2C TREQ/RREQ Interrupt

if(Data_Encode_OTFlag)
{
Data_Encode_OTFlag = FALSE; // One Time Flag
Data_Encode(); // Encodes individual data to 13 Byte Buffer
}

if(Data_Count_var < Max_I2C_Tx_Size) // Max_I2C_Tx_Size is the Maximum number of Bytes to be Sent
{
I2CSlaveDataPut ( baseS , DATA_BUFFER[tmp_var1] ); // Transmits one BYTE
tmp_var1++; // Increments for the next Byte

if(tmp_var1 >= Max_I2C_Tx_Size)
{
Data_Encode_OTFlag = TRUE;
}
}
}

 

One more doubt remains :
Do i need to clear this interrupt ?
I2CSICR |= (1 << DATAIC); // Clear I2C TREQ/RREQ Interrupt

Or can i just ignore it ?

Link to post
Share on other sites

firoz3321, could you use code tags next time. The look like <> in the editor above.

bluehash, Thank you for resetting my THEME setting.  I was not able to access the code tags as the mobile theme was activated (as i have mentioned in the other topic)

I will do as mentioned, Thank you

Link to post
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...