This thread has been locked.

If you have a related question, please click the "Ask a related question" button in the top right corner. The newly created question will be automatically linked to this question.

I2C Interrupt Code for the LM4F232 processor



Anyone;

I am looking for code examples that will allow me to use the LM4F as a master on the I2C and talk 1 or more slave devices using interrupt based code NOT the state machine logic I have seen on various threads. The state machine logic randomly locks up in my code and is not the way I am used to working with I2C devices. Anyone's guidance would be greatly appreciated.

Jeff

  • Jeffrey Jacobson said:
    and is not the way I am used to working with I2C devices.

    And how are we to know - "how" - you are used to working?  (as this appears to be among your qualifications for response...)

    Rejected past "state code" has worked well for hundreds - adding the complexity of interrupt handling may not be fastest/shortest path to your success...  Might it be your "use/mods" of/to, "state machine logic" which, "locked up" - and not the code itself? 

    When introducing multiple devices - to most any bus - we've long found it fastest/easiest to "KISS" - bring up "one" device at a time - in the simplest possible format.  Believe that,  "only then" - would adding the further complexities of interrupts make sense...  

  • Hello Jeff,

    We don't have any example code for interrupt driven I2C master functionality. When you say your code locks up what is happening? Please give us more information to understand the problem better.

    Thanks,
    Sainandan Reddy
  • Sainandan;

    Thank you for the response. In the code that was provided, I randomly see if get 'stuck' in this code:

    void I2CWrite(unsigned char *pucData, unsigned long ulBaseAddress, unsigned long ulOffset,unsigned long ulCount)
    {
    .

    .

    .

        //
        // Wait until the I2C interrupt state machine is idle.
        //
        while(g_ulState != STATE_IDLE);

    }

    Thanks, Jeff

  • Pardon - if memory serves - another poster discovered/reported that, "aspects" of the, "state machine" code you reference had issue.  IIRC - "STATE_IDLE" - just as you list - was among those...  Believe this post was 2-4 months past...