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.

MSP430F5529: MSP430F5529

Part Number: MSP430F5529
Other Parts Discussed in Thread: INA219

Hi,

I am a part of undergraduate student satellite building Team, Team Anant. We are using the MSP430F5529 as the microcontroller for our Electrical Power System. I was writing a code to interface a current sensor (TI's INA219) with the MCU. While transmitting multiple bytes to the INA219, I have used the polling methodology, where the code waits for the TXIFG to be set before loading new data into the TX BUFFER. 

The problem I am having is that the TXIFG is never set and hence my code gets stuck in the while loop. I am having this problem despite enabling and clearing the transmit interrupt. I have attached a snippet of the code below. Any solutions?

 

  • My guess is that you're encountering a NACK from the INA219. The easiest way to do this is by using an incorrect address. (SendMultiByteStart absorbs the initial TXIFG.)

    What is the value of INA219_ADDRESS? It should be something in the range 0x40-0x4F, and needs to match the way the A0/A1 pins are set. [Ref INA219 Data Sheet (SBOS448G) Table 1.]
  •  Hello Bruce,

    Thanks for the prompt reply. I have left the A0 and the A1 pins as they are. Meaning the address should be 0x40? (Correct me if I am wrong).I have defined the value of INA219_ADDRESS as 0x40.

  • If A0/A1 are tied to GND, then I would expect 0x40 to be the correct address (based on Table 1).

    I'm not sure what you mean by "left..as they are". A0/A1 need to be connected to something. If you're using a commercial breakout board, the manufacturer may have done that for you. (While you're checking, check the I2C pullups as well.)

    If you're polling for interrupt bits, you shouldn't enableInterrupt. I don't see an ISR, but if you have one it probably interferes with the polling.
  • Yes, I am using the breakout board by Adafruit. I am really sorry for not mentioning this earlier. 

    You are right I have not written an ISR.

    Will disabling the interrupts solve the problem?

    Am I missing a clearInterrupt() statement somewhere?

    Also, this(https://cdn-learn.adafruit.com/downloads/pdf/adafruit-ina219-current-sensor-breakout.pdf?timestamp=1555244505) documentation does not mention pull-up resistors.

  • I see the pullups on the schematic (p. 18) as well as pulldowns for A0/A1. Adafruit usually includes pullups on their I2C breakouts. So 0x40 would seem to be the correct address.

    I would expect a different symptom from enabling interrupts without an ISR, but maybe there's an interaction I'm not seeing here. In any case, you shouldn't enable them since you want to poll instead. Writing the byte to TXBUF ("Send" functions) will clear the TXIFG, so you don't need to explicitly clear it.

    Which while() are you stopping at? Have you looked at the UCB0 registers? The IFG, IE, and STAT contents should be interesting.
  • Sorry for the delay.

    I am stopping at the first while loop , i.e the one after sendMultiByteStart(), also I have a doubt regarding how exactly do these functions work. The description in the .h file says that the multibytesendnext()

    Continues multi-byte transmission from Master to Slave.

    This function is used by the Master module continue each byte of a multi- byte transmission. This function does the following: -Transmits each data byte of a multi-byte transmission to the Slave

    Parameters
    baseAddress is the base address of the I2C Master module.
    txData is the next data byte to be transmitted

    Modified bits of UCBxTXBUF register.

     but for a transaction to happen the data must be in the shift register right?


    Also i checked the contents of the registers you specified when it was stuck in the while loop and just before that. This was what I  got :

    AT LINE 106:


    AT LINE 107

    IN THE WHILE LOOP :

    I have a few doubts:

    IE is zero.(I disabled the interrupts as you told me to.)

    The  IFG register always remains zero.

    STAT is at 0x10 which means that the bus is busy? Why? It is 0x10 even before I transmit the first byte.

    The CTL1 register changes to 0x92 in the while loop. Which means that it is transmitting a stop condition. You were right, I am indeed getting a NACK, but I am still not able to figure out the reason. 
    Why can't I see the TXBUF register change value?

    TIA
    Parth.

**Attention** This is a public forum