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.

problem using i2c from MSP-EXP430FR5994_Software_Examples

Other Parts Discussed in Thread: MSP-EXP430FR5994, MSP430FR5994

Hello!

I am attempting to use the i2c_driver from BOOSTXL-SENSORS_SensorGUI_MSP430FR5994 within the MSP-EXP430FR5994_Software_Examples. The source code can be found here:

software-dl.ti.com/.../index_FDS.html

I am trying to read a temperature from a MCP9808 over I2C.

I call the function initI2C(void) successfully.

but then i get stuck when calling readI2C(uint8_t ui8Addr, uint8_t ui8Reg, uint8_t *Data, uint8_t ui8ByteCount).

the program hangs on line 301 

  	// WAIT FOR THE FIRST TXBUF EMPTY INTERRUPT BEFORE LOADING TARGET REGISTER
  	while(!(UCB2IFG & UCTXIFG));

Could someone please explain how to use this driver to read/write to an I2C bus? or alternately could someone link me to a compatible easy to use I2C library for the FR5994?

 

  • Hello Colin!

    The BOOSTXL-SENSORS does not have a MCP9808 device on it, and the hang location inside of the readI2C function indicates that the slave device is not acknowledging the slave address + read bit. You need to change the ui8Addr (slave address) for your specific MCP9808 settings, which varies from the A0-A2 pin logic levels. A logic analyzer or oscilloscope will greatly aid in your efforts to debug the system.

    Regards,
    Ryan
  • Thank you for your advice!

    I have changed the slave address to the address to the MCP9808's address (0x18) and I have hooked up my system to the oscilloscope. Unfortunately I aam still encountering errors. Firstly it appears that no data is being transmitted on the I2C bus. The scope remains flat on both the SDA and SCL lines, there is no indication the the Address code or the read/write bit are being transmitted at all, let alone acknowledged. I have tried both reading and writing over the bus to no avail. Both the SDA and SCL pins are outputting a solid ~5V.

    I am trying to read a temperature, and convert it to a voltage that will be written to a MCP4725 DAC.

    I believe my error lies within the software setup of the I2C bus:

    #include <stdio.h>
    #include <stdint.h>
    #include <stdlib.h>
    #include <stdbool.h>
    #include <msp430.h>
    
    #include "i2c_driver.h"
    
    double convertHexToTemp(uint8_t *tempData);
    uint8_t* convertTempToVolt(double Temp);
    
    int main(void) {
        WDTCTL = WDTPW | WDTHOLD;	// Stop watchdog timer
    
    	initI2C();
    
    	printf("I2C initialized!\n");
    
    	const uint8_t tempSensorAddress = 0x18;
    	const uint8_t tempSensorRegistery = 0x05;
    
    	const uint8_t DACAddress = 0x62;
    
    	while(true) {
    		uint8_t * TempData = malloc(sizeof(uint8_t) * 2);
    		readI2C(tempSensorAddress, tempSensorRegistery, TempData, 0x02);
    
    	 	printf("Data transmission complete\n");
    
    		double Temperature = convertHexToTemp(TempData);
    		printf("This is the Temp! %f \n" , Temperature);
    
    		uint8_t * voltCode = convertTempToVolt(Temperature);
    
    		writeI2C(DACAddress, voltCode[0], voltCode + 1, 0x01);
    		printf("Temperature written\n");
    	}
    }
  • The maximum allowed voltage on any MSP430 pin is 3.6 V, the FR5994 is most likely unable to control the 5V I2C lines.

    Regards,
    Ryan
  • Thank you for all of your help so far Ryan!

    I have tested the system after adjusting the I2C bus voltage to 3.3 volts; however, I am still having the same problem. There is no data transmission on the I2C bus, the address code is never sent. The only difference is that the scope reads both the SDA and SCL lines at ~3 volts. Additionally I tested my system with a different MSP430FR5994 with the same results. I believe that this is most likely a software problem, but I don't know how to begin solving it.

    Thanks Again!
    -Colin
  • Colin,

    You've stripped out too much of the example code and have as such broken the I2C communication, for example you need to clear the LOCKLPM5 bit (PM5CTL0 &= ~LOCKLPM5;) to disable the GPIO power-on default high-impedance mode. It would be best if you reviewed the MSP430FR5994 DriverLib I2C examples to get a better understanding of how to initialize and use the eUSCI peripheral correctly.

    Regards,
    Ryan

**Attention** This is a public forum