Feroze 0 Posted March 7, 2013 Share Posted March 7, 2013 Hello all, I am new to the stellaris. I found a Interrupt based I2C code for Burst mode from Here : 169882.aspx That code is transmitting as a MASTER. while in my application i will be needing to transmit approx 13 bytes of data as a SLAVE. I have posted a similar topic here : http://e2e.ti.com/support/microcontrollers/stellaris_arm/f/471/p/249955/875378.aspx It didnt help me as yet. All i need is to transmit 13 bytes of data from my controller (SLAVE) to the MASTER which requests the data. I will have to be using some kind of interrupt driven code so as not to have any blocking code. Kindly help me out. Feroze 1 Quote Link to post Share on other sites
aBUGSworstnightmare 1 Posted March 8, 2013 Share Posted March 8, 2013 Hi, so, LM3S2965 will act as a I2C slave. right? Then you should have a look at the example 'slave_receive_interrupt' which is located in the example folder of your Stellarisware package (Stellarisware/examples/peripherals/i2C/). aBUGSworstnightmare Feroze 1 Quote Link to post Share on other sites
Feroze 0 Posted March 8, 2013 Author Share Posted March 8, 2013 I will right-away look at it. couldnt find anything related to burst mode in google also Feroze 1 Quote Link to post Share on other sites
Feroze 0 Posted March 8, 2013 Author Share Posted March 8, 2013 I have infact already gone through this code. I dont think this transmits multi bytes (in my case i need to transmit 13 bytes) Feroze 1 Quote Link to post Share on other sites
Feroze 0 Posted March 8, 2013 Author Share Posted March 8, 2013 so, LM3S2965 will act as a I2C slave. right? Yes it will be the slave , but the Slave will have to transmit 13 bytes of data to the Master (when requested) Feroze 1 Quote Link to post Share on other sites
aBUGSworstnightmare 1 Posted March 8, 2013 Share Posted March 8, 2013 This examples only tramsits one byte of data. So: what is stopping you to expand it so it transfers 13 bytes? Sound to me as if your (only) looking for a 'turn-key solution' for your problem. Quote Link to post Share on other sites
Feroze 0 Posted March 8, 2013 Author Share Posted March 8, 2013 My question was about the Burst Mode for SLAVE. There is no specification or example found. Not mentioned in the Driver Library nor in the datasheet of the Micro. Quote Link to post Share on other sites
aBUGSworstnightmare 1 Posted March 8, 2013 Share Posted March 8, 2013 ... that's because there is no Burst Mode for slaves available ! Your 'slave' needs to examine it's status by calling 'I2CSLAVEStatus()' (either by polling or by using an interrupt (!)) to determine if the master requested a send or receive operation. Depending on the type of operation request you can call 'I2CSlaveDataPut()' or 'I2CSlaveDataGet()'. Since you need to send send 13bytes of data you will end up with 13 'I2CSlaveDataPut()' operations. My LM4F120H5QR Users manual gives me this flowchart for Slave operation: Should be similar for your Lm3S device. aBUGSworstnightmare Rickta59, gwdeveloper and bluehash 3 Quote Link to post Share on other sites
gwdeveloper 275 Posted March 9, 2013 Share Posted March 9, 2013 @aBUGSworstnightmare, are you going to do the rest of his homework too? You already wrote a rockin' API to get I2C started for most. I've made some mods to it to allow use on the evalbot too and currently working on making it use interrupts. I'm reading 22 bytes from a slave with no issues; but of course, the slave is set to transmit the number of bytes that the master requests. Quote Link to post Share on other sites
aBUGSworstnightmare 1 Posted March 10, 2013 Share Posted March 10, 2013 @aBUGSworstnightmare, are you going to do the rest of his homework too? You already wrote a rockin' API to get I2C started for most. I've made some mods to it to allow use on the evalbot too and currently working on making it use interrupts. I'm reading 22 bytes from a slave with no issues; but of course, the slave is set to transmit the number of bytes that the master requests. Hi, Would be great if you share the 'interrupt' version too. I was also thinking of adding interrupt support to the API, but I will modify it for use with TI-RTOS. aBUGSworstnightmare Quote Link to post Share on other sites
gwdeveloper 275 Posted March 11, 2013 Share Posted March 11, 2013 I will do. Do you want to start a git for your software and let me fork it? Quote Link to post Share on other sites
Feroze 0 Posted March 11, 2013 Author Share Posted March 11, 2013 I am most probably wrong but is the this going in the right direction ? /// 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; tmp_var1++) { I2CSlaveDataPut ( baseS , DATA_BUFFER[tmp_var1] ); } } The interrupt handler will call the ‘I2CSlaveDataTx', the \for loop\ will transmit the data (Max_I2C_Tx_Size bytes) through I2C.If i keep transmitting the data using the for loop, will the master actually be receiving it ? Quote Link to post Share on other sites
Feroze 0 Posted March 11, 2013 Author Share Posted March 11, 2013 OK so i just now googled and found your API here : http://e2e.ti.com/support/microcontrollers/stellaris_arm/f/471/t/235926.aspx My doubt is, in the function 'I2CReadData' \param ucReg is the register to start reading from. What will be the 'ucReg', can i point it to some buffer at the slave end ? Can this read from the Slave (LM3S) directly or the SLAVE have to be transmitting the data at the same time ? Quote Link to post Share on other sites
aBUGSworstnightmare 1 Posted March 11, 2013 Share Posted March 11, 2013 OK so i just now googled and found your API here : http://e2e.ti.com/support/microcontrollers/stellaris_arm/f/471/t/235926.aspx My doubt is, in the function 'I2CReadData' \param ucReg is the register to start reading from. What will be the 'ucReg', can i point it to some buffer at the slave end ? Can this read from the Slave (LM3S) directly or the SLAVE have to be transmitting the data at the same time ? Hi, this API is for I2C MASTER MODE only! Hi, so, LM3S2965 will act as a I2C slave. right? Then you should have a look at the example 'slave_receive_interrupt' which is located in the example folder of your Stellarisware package (Stellarisware/examples/peripherals/i2C/). aBUGSworstnightmare You're nearly there! Again: look at this example, expand it with a useful routine (I would prefer to check TREQ-bit before each data send transfer) and you got it. Your master should do a data write first to let the slave know how much data it is requesting (Max_I2C_Tx_Size); you can skip this if you have a fixed number of bytes. But remember: You will have to adjust the code each time if your slave has to transmit less or more bytes. aBUGSworstnightmare Quote Link to post Share on other sites
Feroze 0 Posted March 12, 2013 Author Share Posted March 12, 2013 As of now the requirement is that a MAXIMUM of 13 Bytes have to be sent and not more than 13. In this case , as you have mentioned, i believe the master need not mention the data length. I would prefer to check TREQ-bit before each data send transfer aBUGSworstnightmare Does that mean that the Transmit Request Bit will be set High by the Master after each BYTE being Received ?or do we have to program the MASTER module to Request the Data for 13 bytes (13 bytes being hard coded in the MASTER ??) ? 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.