LabVIEW Embedded

cancel
Showing results for 
Search instead for 
Did you mean: 

Setting LM3S8962 as I2C slave

Hi,

 

Im using the LabVIEW embedded module for ARM microcontrollers upon the LM3S8962 in order to create I2C communication between two devices, the other being a MCF51JM128 Coldfire microprocessor. I've been able to set the LM3S8962 as the master device and write data to the Coldfire as well as read data from the Coldfire, whilst the coldfire is the set as the slave device.

 

Now, for the purpose of potentially communicating among several LM3S8962 boards, is there any way to set the LM3S8962 as the slave device? It appears that the LM3S8962 is inherently set as a master device which adresses other slave devices. Is it possible to have the LM3S8962 adressed as a slave?

Kind Regards  

0 Kudos
Message 1 of 2
(5,881 Views)

Yes this is possible.  The LM3S8962 hardware supports both Master and Slave Mode I2C according to page 385 of the data sheet below.

LM3S8962 Microcontroller Data Sheet
http://www.keil.com/dd/docs/datashts/luminary/lm3s8962.pdf

“The Stellaris® I2C module supports both sending and receiving data as either a master or a slave, and also supports the simultaneous operation as both a master and a slave.”
So this confirms that the hardware supports slave mode.  To determine if we exposed this in LabVIEW I created a project with the LM3S8962 as the target device.  The ARM palette has an SPI and I2C sub palette.  These are the cross platform SPI and I2C functions, i.e. they should work on all supported ARM chips.  This is why they don’t provide much functionality; all supported ARM devices need to support these functions.  There is a more advanced I2C palette specifically designed for the LM3S8962.
 
You can find the ‘Advanced’ I2C palette in ARM>>EK-LM3Sxxxx >>Stellaris Ware>>I2C.  This palette provides much more functionality, including things like I2C Slave Enable, I2C Slave Init etc.  The help files on these Vis are only mildly useful, but this is how you enable I2C slave mode on the LM3S8962.
 
I want to know what those I2C VI are doing to confirm that they are actually enabling I2C slave mode.  If you open the VI you will find a call library function node that is not pointing to any code.  This would break in the desktop environment, but has been overloaded in LV Embedded and basically acts like an in line C call.  There is a comment on the block diagram with the function call to I2CSlaveEnable.  To find where this is coming from we can use an awesome feature in Visual Studio to search for text in side files in a given directory.  Hit Ctrl+Shift+F in visual studio gives us  the Find and Replace in Files and Folders dialog.  From there I searched for I2CSlaveEnable in C:\Keil\ARM. I really want the C and H files containing this function and luckily the search found them at C:\Keil\ARM\RV31\LIB\Luminary\SRC\i2c.c, and C:\Keil\ARM\INC\Luminary\i2c.h.
 
The header file doesn’t tell us a whole lot, but the C file includes a nice comment on the function:
 
//*****************************************************************************
//
//! Enables the I2C Slave block.
//!
//! \param ulBase is the base address of the I2C Slave module.
//!
//! This will enable operation of the I2C Slave block.
//!
//! \return None.
//
//*****************************************************************************
 
So now we know that we are actually calling code to enable the I2C device in slave mode.

-Michael
AE-NIC

Regards,

Mike S
NI AE
0 Kudos
Message 2 of 2
(5,864 Views)