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.

MSP432P401R: eeprom issue while reading data

Part Number: MSP432P401R


Hi,

This is my first project on MSP432 . I have eeprom(24AA128) and temperature sensor connected to master MSP432 via I2C. I could write data to eeprom at any locations but I am facing data repetition while reading from the same location. Please see the read and write portion of the code below.

void eeprom_write() {
/* Select Port 1 for I2C - Set Pin 6, 7 to input Primary Module Function
*/

char eeprom_data[10] = "ABCD_EFGH";
MAP_GPIO_setAsPeripheralModuleFunctionInputPin(
GPIO_PORT_P1,
GPIO_PIN6 + GPIO_PIN7,
GPIO_PRIMARY_MODULE_FUNCTION);
/* Initializing I2C Master to SMCLK at 100khz with no autostop */
MAP_I2C_initMaster(EUSCI_B0, &i2cConfig);
/* Specify slave address */
MAP_I2C_setSlaveAddress(EUSCI_B0, 0x51);
/* Enable I2C Module to start operations */
MAP_I2C_enableModule(EUSCI_B0);
/* Making sure the last transaction has been completely sent out */
while (MAP_I2C_masterIsStopSent(EUSCI_B0));
MAP_I2C_masterSendMultiByteStart(EUSCI_B0, 0x00); // Start + 1Byte Reg Address High

MAP_I2C_masterSendMultiByteNext(EUSCI_B0, 0x00); // Start + 1Byte Reg Address Low
for (j = 0; j <= 32; j++)
{
sprintf(str, "0x%02x",eeprom_data[j] );
data = (int) strtol(str, NULL, 0);
if (j == 32)
MAP_I2C_masterSendMultiByteFinish(EUSCI_B0, data);
else
MAP_I2C_masterSendMultiByteNext(EUSCI_B0, data);
}
}

void eeprom_read()  {
/* Select Port 1 for I2C - Set Pin 6, 7 to input Primary Module
* Function,(UCB0SIMO/UCB0SDA, UCB0SOMI/UCB0SCL).
*/
MAP_GPIO_setAsPeripheralModuleFunctionInputPin(
GPIO_PORT_P1,
GPIO_PIN6 + GPIO_PIN7,
GPIO_PRIMARY_MODULE_FUNCTION);
/* Initializing I2C Master to SMCLK at 100khz with no autostop*/
MAP_I2C_initMaster(EUSCI_B0, &i2cConfig);
/* Specify EEPROM address */
MAP_I2C_setSlaveAddress(EUSCI_B0, 0x51);
/* Enable I2C Module to start operations */
MAP_I2C_enableModule(EUSCI_B0);
rx_data = 0;
for(j = 0; j < length; j++) {
/* Making sure the last transaction has been completely sent out */
while (MAP_I2C_masterIsStopSent(EUSCI_B0));
/* Send out EEPROM word address (2 databytes) */
MAP_I2C_masterSendMultiByteStart(EUSCI_B0, 0x00);
MAP_I2C_masterSendMultiByteNext(EUSCI_B0, tx_data[j]);
/*---------------------------------------------*/
/* Now we need to initiate the read*/
/* Wait until Byte has been output to shift register*/
while (!(EUSCI_B0->IFG & EUSCI_B_IFG_TXIFG0));
/*Send the restart condition,read one byte,send the stop condition right away*/
EUSCI_B0->CTLW0 &= ~(EUSCI_B_CTLW0_TR);
EUSCI_B0->CTLW0 |= EUSCI_B_CTLW0_TXSTT;
while (MAP_I2C_masterIsStartSent(EUSCI_B0));
EUSCI_B0->CTLW0 |= EUSCI_B_CTLW0_TXSTP;
while (!(EUSCI_B0->IFG & EUSCI_B_IFG_RXIFG0));
rx_data = EUSCI_B0->RXBUF;
while (!(UCA0IFG & UCTXIFG));
UCA0TXBUF = rx_data;
}
}

Please find the Output that I got on my UART terminal with register on first and its data on second,

0x00 A 0x01 B 0x02 B 0x03 C 0x04 D 0x05 _ 0x06 E 0x07 F 0x08

0x00, 0x01... are the registers I used to write the data. You could see a repetition of the actual data on register 0x01 and 0x02. 

when I provided with, eeprom_data1[] = "ABCD_EFGH" and eeprom_data2[] = "IJKL_MNOP", I could find the same repetition of data in registers 2 and 3.

 

  • Abhay,

    What happened to G and H? 

    It looks like you are transmitting w/ a 100kHz clock speed. Are you powering the 24AA128 with a voltage between 1.7 and 2.5V?

    BR,

    Seong

  • Seong,

    I have to tell you sorry for 2 reasons. First of all, am Sorry for the wrong output sequence. Actually am getting G at 0x08. I forgot to copy that also. The output was missing H. This is also the case for next set of datas stored in eeprom as I have mentioned above.

    Second, I have used eeprom with part no. 24LC128-I. I have powered  it with a voltage of 3.3v .

    Thanks,

    Abhay

  • Abhay,

    If you are powering the EEPROM with 3.3V, it is configured to use 400kHz clock speed. Try initializing the MSP432'S I2C driver to use 400kHz as well.

    BR,

    Seong

     

  • Seong,

    I tried with 400khz. But when I tried the same, I could not initialise temperature sensor which is also connected with I2C. I commented the initialisation steps for temperature sensor, but the read function could not read back the expected data from eeprom. It showed up as : ABC__EFG. Could you please check more on the same issue. 

  • Abhay,

    Are you using a custom board? What pull ups are you using? Have you observed the signals on an oscilloscope? If so, please share captures that clearly shows what the signal looks like.

    BR,

    Seong

  • Hi Abhay,

    I see that you started a new thread. Let's continue the discussion here (I will be closing the other thread). 

    From your new thread, I see that you've used a logic analyzer and noted that the clock frequency isn't configured correctly.

    If you refer to section 11.2 in the MSP432 DriverLib User's Guide, you'll see a list of APIs that must be invoked in the a specific order.

    The following line of code is missing from what you shared in your original post. Try adding this one.

    /* Set Master in transmit mode */
    MAP_I2C_setMode(EUSCI_B0_BASE, EUSCI_B_I2C_TRANSMIT_MODE);

    BR,

    Seong

  • Hi Seong,

    Thanks for your replies first of all. Coming back to your questions, Yes I am using a coustom board with pull up 2.1k. I have used an oscilloscope, please find the output signal  image worked on 100Khz clock frequency.


    As you told, I have included,

    /* Set Master in transmit mode */
    MAP_I2C_setMode(EUSCI_B0_BASE, EUSCI_B_I2C_TRANSMIT_MODE);
    I had tried this in my code, but there is no change in the output. I have used SDK, simplelink_msp432p4_sdk_2_20_00_12, from which I had used, i2c_master_repeated_start_singlebyte_nointr_master.c to configure my I2C.
    In it I didn't find those code you had told. I don't know this is the actual code to use to configure I2C. Could you please check on the same.  

    Thanks, Abhay

     

  • Abhya,

    That is an out-dated SDK version from a year ago. Try using the latest, v3.20.00.06. You can download it here.

    Also use the latest version of CCS. Download it here.

    BR,

    Seong

  • Seong,

    We have already completed working with interfaces and devices connected to it and only faced issues as told before. Could you please help me to resolve this issue from my SDK end. 

    Thanks,

    Abhay

  • Abhay,

    I highly recommend that you update and use the latest SDK as many bug fixes have been made to the drivers since a year ago.

    BR,

    Seong

**Attention** This is a public forum