Jump to content
43oh

I2C Slave - Burst Mode - LM3S2965


Recommended Posts

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.

Link to post
Share on other sites

... 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:

post-100-14264605238902_thumb.jpg

 

Should be similar for your Lm3S device.

 

aBUGSworstnightmare 

 

Link to post
Share on other sites

@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. :blink:

Link to post
Share on other sites

@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. :blink:

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

Link to post
Share on other sites

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 ?

Link to post
Share on other sites

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 ?

Link to post
Share on other sites

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

Link to post
Share on other sites

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 ??) ?

 

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...