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.

MSP430G2231 USI I2C w/ TMP100

Other Parts Discussed in Thread: TMP100

I have this code I wrote for I2C via USI, but I am having problems getting it to run properly. The basic idea is to get the temperature from the TMP100 1 time every 10 seconds for a total ten times. The problem is I cannot get the code to get past line 79 if it step through it. It hangs up and provides an error. 

Any insight would be great.

Thanks

http://pastebin.com/1Fks3zGs

  • Well, your while loop simply sets USIIFG, whch triggers an immediate USI interrupt. When the ISR returns, the itnerrutp is immediately triggered again by the while loop - independent of any job done by the ISR. So it completely breaks the state machine you implemented in teh ISR.

    Inside the ISR you do busy-waiting delays. Which is a bad, bad, bad thing. ISRs have to be simple, fast in-and-out code. Else you wouldn't need them and could do all the job in main as well. And you wouldn't need a state machine at all.

    You should rework your concept a bit. :)

  • Well, running the basic code without the interrupt I am running into problems. I can send the slave address and get ACK and can send the pointer register and get ACK but when I send the slave address + W I get NACK. What is going on? Anything look wrong with the state machine process.

    Thanks

  • Well, you have the hardware and the debuger.
    You should single-step through the transfer (hoping that the slave doesn't timeout when the I2C baudrate goes town to 0.0001Bd).
    And double-check what you write when.
    I didn't see anyhting obvious.

    If ou cannot figure it out by staring at the code, you should simulate it dry, with a piece of paper and a pencil. Play microcontroller by yourself. Maybe you'll find the point where reality leaves the planned path.

**Attention** This is a public forum