Feroze 0 Posted March 12, 2013 Author Share Posted March 12, 2013 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++; } } } Quote Link to post Share on other sites
Feroze 0 Posted March 12, 2013 Author Share Posted March 12, 2013 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 occursSo 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. Quote Link to post Share on other sites
aBUGSworstnightmare 1 Posted March 12, 2013 Share Posted March 12, 2013 Hi, you need to register your 'ISR_I2C1_SlaveDataTx' to 'startup_ccs.c' and you need to enable the coresponding I2C interrupts (and the global interrupt) to get it fired. Refer to the Stellaris Launchpad Workshop Manual for an example on how to use interrupts. aBUGSworstnightmare Quote Link to post Share on other sites
Feroze 0 Posted March 12, 2013 Author Share Posted March 12, 2013 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 InterruptOr can i just ignore it ? Quote Link to post Share on other sites
bluehash 1,581 Posted March 12, 2013 Share Posted March 12, 2013 firoz3321, could you use code tags next time. The look like <> in the editor above. Quote Link to post Share on other sites
Feroze 0 Posted March 12, 2013 Author Share Posted March 12, 2013 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 Quote Link to post Share on other sites
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.