• Join
  • Sign In with my.TI Login
Texas Instruments
  • Products
  • Applications
  • Tools & Software
  • Support & Community
  • Sample & Buy
  • About TI
Sample & Purchase Cart Sample & Purchase Cart
  • Search
  • Advanced
TI E2E™ Community
  • Support Forums
  • Blogs
  • Groups
  • Videos
  • 简体中文
  • More ...
TI Home » TI E2E Community » Support Forums » Microcontrollers » Stellaris® ARM® Microcontrollers » Stellaris® ARM® LM3S Microcontrollers Forum » I2C Master Busy
Share
Stellaris® ARM® Microcontrollers
  • Forum
Options
  • Subscribe via RSS
Helpful Stellaris® LM4F Series Links
  • LM4F Series
  • Stellaris PinMux Utility
  • Stellaris® LM4F120 LaunchPad
  • LM4F MCU Applications
  • LM4F MCU Video
  • ARM Cortex-M4F Whitepaper
  • Stellaris MCU Brochure
  • LM4F232 Eval Kit
  • Forums

    I2C Master Busy

    This question is not answered
    Stephen Griffiths
    Posted by Stephen Griffiths
    on May 02 2012 14:49 PM
    Intellectual345 points

    I'm running into an issue with I2C where I never break out of this while loop:  while(I2CMasterBusy(m_I2CBus));   I have 16kOhm pullup resistors on both th SDATA and SCLOCK.  They are not connected to a device, but I think it should still work.

    I use the following commmands to setup the I2c

    //I2C1
    SysCtlPeripheralEnable(SYSCTL_PERIPH_I2C1); //(m_Periferal); //SYSCTL_PERIPH_I2C0
    SysCtlPeripheralEnable(SYSCTL_PERIPH_GPIOA); //(m_Port); //SYSCTL_PERIPH_GPIOB
    GPIOPinConfigure(GPIO_PA6_I2C1SCL);
    GPIOPinConfigure(GPIO_PA7_I2C1SDA);
    GPIOPinTypeI2C(SYSCTL_PERIPH_GPIOA, GPIO_PIN_6 | GPIO_PIN_7 ); //m_Port, m_ClockPin | m_DataPin); //SYSCTL_PERIPH_GPIOB, GPIO_PIN_2 | GPIO_PIN_3
    I2CMasterInitExpClk(I2C1_MASTER_BASE, SysCtlClockGet(), false); //false = 100 Khz, true = 400KHz m_I2CBus
    I2CMasterEnable(I2C1_MASTER_BASE); //I2C0_MASTER_BASE

    Then I have a send command function that gets called in the Main that should send I2C bytes.

    int SendCommand(NanoMotionASICCommands commandCode, short int commandValue)
    {
    unsigned char buf[2];

    unsigned long  m_I2CBus =  I2C1_MASTER_BASE;

    if(commandCode < 1)
    return -1;

    //printf("Writing Command: %d %d\n", commandCode, commandValue);

    //Set Address Write
    I2CMasterSlaveAddrSet(m_I2CBus, ID_I2C_ADDR, false);

    //Send Command Code Byte
    I2CMasterDataPut(m_I2CBus, commandCode);
    I2CMasterControl(m_I2CBus, I2C_MASTER_CMD_BURST_SEND_START); // I2C_MASTER_CMD_SINGLE_SEND
    while(I2CMasterBusy(m_I2CBus));  << Always get stuck here !!!!

    //Divide Command Value into 2 bytes. Send in Little Endian (LSB first)
    memcpy(buf, &commandValue, 2);

    I2CMasterDataPut(m_I2CBus, buf[0]);
    I2CMasterControl(m_I2CBus, I2C_MASTER_CMD_BURST_SEND_CONT); //I2C_MASTER_CMD_SINGLE_SEND
    while(I2CMasterBusy(m_I2CBus));

    //Send Command Value
    I2CMasterDataPut(m_I2CBus, buf[1]);
    I2CMasterControl(m_I2CBus, I2C_MASTER_CMD_BURST_SEND_FINISH); // I2C_MASTER_CMD_SINGLE_SEND
    while(I2CMasterBusy(m_I2CBus));

    return 0;
    }

    Why is this the case?  What would make it return busy always? Any suggestions?

    Report Abuse
    • Reply
    You have posted to a forum that requires a moderator to approve posts before they are publicly available.
    All Replies
    • cb1_mobile
      Posted by cb1_mobile
      on May 02 2012 16:04 PM
      Guru21970 points

      Here is an extract from a TI I2C Slave ADC datasheet - expect it is helpful:

      "Every byte transmitted on the I2C bus, whether it is address or data, is acknowledged with an acknowledge bit.   When the master has finished sending a byte (eight data bits) to a slave, it stops driving SDA and waits for the slave to acknowledge the byte. The slave acknowledges the byte by pulling SDA low."

      Thus your "test" of I2C - minus any connected, proper I2C device - appears doomed.  Suggest that you acquire a small capacity EEprom - there is a past application note showing Stellaris "talking" to a small Atmel EEprom via I2C.  (EEprom is about the simplest device to build confidence)

      Also don't especially like your order of I2C transacting - a very recent forum post  - blessed both by Stellaris Sue & independent forum user - provides I2C set-up/guidance from both TI responder and this reporter.

      http://e2e.ti.com/support/microcontrollers/stellaris_arm_cortex-m3_microcontroller/f/473/p/169023/639164.aspx#639164

      Suggest that you follow this basic guide - later refine/improve as/if you're able...   Simplicity is your friend @ this stage...

      Report Abuse
      • Reply
      You have posted to a forum that requires a moderator to approve posts before they are publicly available.
    • Stellaris Mitch
      Posted by Stellaris Mitch
      on May 02 2012 16:42 PM
      Intellectual2170 points

      Hi Stephen,

      Can you please indicate which processor you are using?

      Report Abuse
      • Reply
      You have posted to a forum that requires a moderator to approve posts before they are publicly available.
    • Stephen Griffiths
      Posted by Stephen Griffiths
      on May 03 2012 21:56 PM
      Intellectual345 points

      Yes.  Of course.  I'm using the lm3s9d96.  THanks for your help.

      Report Abuse
      • Reply
      You have posted to a forum that requires a moderator to approve posts before they are publicly available.
    • Stephen Griffiths
      Posted by Stephen Griffiths
      on May 03 2012 21:57 PM
      Intellectual345 points

      Hmm... I see.  I didn't realize this.  I'll try that out. Thanks.  That was very helpful.

      I'm using the lm3s9d96.  

      Report Abuse
      • Reply
      You have posted to a forum that requires a moderator to approve posts before they are publicly available.
    • Stellaris Mitch
      Posted by Stellaris Mitch
      on May 04 2012 12:17 PM
      Intellectual2170 points

      Hi Stephen,

      As CB1 points out, you won't get an ACK since there is no slave device. However, I would expect the busy status bit to toggle normally as long as the clock is not held low. The suggestion to simplify is always a good idea to isolate the problem. It would also be useful to see the full setup for the processor in your application code.

      As a side note, there's a loopback bit in the MCR register if you want to test basic I2C code (examples of that are in the top level StellarisWare /examples directory).

      Report Abuse
      • Reply
      You have posted to a forum that requires a moderator to approve posts before they are publicly available.
    TI E2E™ Community
    • Support Forums
    • Blogs
    • Videos
    • Groups
    • Site Support & Feedback
    • Settings
    TI E2E™ Community Groups
    • TI University Program
    • Make the Switch
    • Microcontroller Projects
    • Motor Drive & Control
    Other Communities
    • Deyisupport
    • Designsomething.org
    • beagleboard.org
    • TI on Element 14
    • TI on TechXchangeSM
    Other Technical & Support Resources
    • WEBENCH® Design Center
    • Product Information Centers
    • Technical Documents
    • TI Design Network
    • TI Technical Articles
    • TI Training

    All content and materials on this site are provided "as is". TI and its respective suppliers and providers of content make no representations about the suitability of these materials for any purpose and disclaim all warranties and conditions with regard to these materials, including but not limited to all implied warranties and conditions of merchantability, fitness for a particular purpose, title and non-infringement of any third party intellectual property right. TI and its respective suppliers and providers of content make no representations about the suitability of these materials for any purpose and disclaim all warranties and conditions with respect to these materials. No license, either express or implied, by estoppel or otherwise, is granted by TI. Use of the information on this site may require a license from a third party, or a license from TI.

    Content on this site may contain or be subject to specific guidelines or limitations on use. All postings and use of the content on this site are subject to the Terms of Use of the site; third parties using this content agree to abide by any limitations or guidelines and to comply with the Terms of Use of this site. TI, its suppliers and providers of content reserve the right to make corrections, deletions, modifications, enhancements, improvements and other changes to the content and materials, its products, programs and services at any time or to move or discontinue any content, products, programs, or services without notice.

    Follow Us Texas Instruments on Facebook Texas Instruments on Twitter Texas Instruments on LinkedIn Texas Instruments on Google+
    TI Worldwide | Contact Us | my.TI Login | Site Map | Corporate Citizenship | mobile m.ti.com (Mobile Version)

    TI is a global semiconductor design and manufacturing company. Innovate with 100,000+ analog ICs and
    embedded processors, along with software, tools and the industry’s largest sales/support staff.

    © Copyright 1995-2013 Texas Instruments Incorporated. All rights reserved.
    Trademarks | Privacy Policy | Terms of Use