Author Topic: Using the second IIC interface  (Read 6725 times)

Offline mhoneywill

  • Full Member
  • ***
  • Posts: 173
    • View Profile
Using the second IIC interface
« on: October 19, 2010, 06:22:20 PM »
Hi Mark,

We need to use the second IIC interface on a LM3S1968 chip, as well as the first. Is this as simple as changing the channel number in the configuration routine, and generating a new handle using fnOpen?

static void fnConfigIIC_Interface(void)
{
    IICTABLE tIICParameters;

    tIICParameters.usSpeed = 400;                                        // 400k
    tIICParameters.Rx_tx_sizes.TxQueueSize = 256;                         // transmit queue size
    tIICParameters.Rx_tx_sizes.RxQueueSize = 256;                         // receive queue size
    tIICParameters.Task_to_wake = OWN_TASK;                                     // no wake on transmission
    tIICParameters.Channel = 0;
    IICPortID = fnOpen( TYPE_IIC, FOR_I_O, &tIICParameters); // open the channel with defined configurations
}

Will the simulator support two IIC networks, or will the same simulator code be called for both ports?

Regards

Martin

Offline mark

  • Global Moderator
  • Hero Member
  • *****
  • Posts: 3112
    • View Profile
    • uTasker
Re: Using the second IIC interface
« Reply #1 on: October 20, 2010, 02:54:23 AM »
Hi Martin

Yes (should be) - for each I2C available in the device there is a set of variables and routines (mainly the channels own interrupt handlers). Therefore you can use them in the same way as UARTs (open 0, 1, 2, 3 etc. depending on how many the device has) and maintain a handle for each for use when reading, writing etc.

Regards

Mark

Offline mhoneywill

  • Full Member
  • ***
  • Posts: 173
    • View Profile
Re: Using the second IIC interface
« Reply #2 on: October 22, 2010, 04:39:25 PM »
After some investigation I've realised that the simulator does not support more than one IIC interface in its current setup. In fact it can cause weird problems as different busses trample over each other.

A quick look, and I think I should be able to pass the "Channel" to fnSimIIC_devices and then use this to differentiate different busses. I'll look at this in more detail later. I just wanted to post here to ensure that other people were aware of this limitation.

What I've done is to change all calls to fnSimIIC_devices to pass the channel.

unsigned char fnSimIIC_devices(QUEUE_HANDLE Channel, unsigned char ucType, unsigned char ucData)

Then I've added the line
    if(Channel) return 0;
As the first line in  fnSimIIC_devices, so that processing is aborted for any other channel than channel 0. This seems to work as a quick fix.

unsigned char fnSimIIC_devices(QUEUE_HANDLE Channel, unsigned char ucType, unsigned char ucData)
{
    if(Channel) return 0;
« Last Edit: October 22, 2010, 06:31:57 PM by mhoneywill »

Offline mark

  • Global Moderator
  • Hero Member
  • *****
  • Posts: 3112
    • View Profile
    • uTasker
Re: Using the second IIC interface
« Reply #3 on: October 24, 2010, 03:47:18 PM »
Hi Martin

Yes, I forgot about this restriction. I known that someone has already done it (due to the requirement for simulating multiple channels) but I haven't yet.

What it needs is the channel parameter and then all variables and arrays in the simulator need to be made into arrays with another channel dimension. Then it will work for multiple channels.

May be the chip select needs to be handled slightly differently too?

Regards

Mark

Offline mhoneywill

  • Full Member
  • ***
  • Posts: 173
    • View Profile
Re: Using the second IIC interface
« Reply #4 on: October 24, 2010, 06:18:23 PM »
That was my plan too Mark, to create arrays.

I'd just forgotten that the IIC simulator currently only worked for one channel so it was causing problems when I was using two.

When you say "chip selects" do you mean the chip selects of the IIC chips

Offline mark

  • Global Moderator
  • Hero Member
  • *****
  • Posts: 3112
    • View Profile
    • uTasker
Re: Using the second IIC interface
« Reply #5 on: October 24, 2010, 08:08:17 PM »
Martin

Oops. I was thinking about SPI (its simulator checks which CS line is low) since that uses chip selects - I2C doesn't... of course.

regards

Mark