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.

Working with i2c

Hi there, I'm currently trying to work with i2c on my tm4c123gxl. as of now, i'm trying to receive the WHO_AM_I message from a MMA8452Q accelerometer. I'm modified the loop example, but i still end up receiving an echo of what i sent. any idea what went wrong? i am also declare that i'm quite new to i2c. thanks in advance.

http://www.freescale.com/files/sensors/doc/data_sheet/MMA8452Q.pdf

#include <stdbool.h>
#include <stdint.h>
#include "inc/hw_i2c.h"
#include "inc/hw_memmap.h"
#include "inc/hw_types.h"
#include "driverlib/gpio.h"
#include "driverlib/i2c.h"
#include "driverlib/pin_map.h"
#include "driverlib/sysctl.h"
#include "driverlib/uart.h"
#include "utils/uartstdio.h"
//
//*****************************************************************************

//*****************************************************************************
//
// Number of I2C data packets to send.
//
//*****************************************************************************
#define NUM_I2C_DATA 1

//
//*****************************************************************************
#define SLAVE_ADDRESS 0x1C

//*****************************************************************************
//
// This function sets up UART0 to be used for a console to display information
// as the example is running.
//
//*****************************************************************************
void
InitConsole(void)
{
	//
	// Enable GPIO port A which is used for UART0 pins.
	// TODO: change this to whichever GPIO port you are using.
	//
	SysCtlPeripheralEnable(SYSCTL_PERIPH_GPIOA);

	//
	// Configure the pin muxing for UART0 functions on port A0 and A1.
	// This step is not necessary if your part does not support pin muxing.
	// TODO: change this to select the port/pin you are using.
	//
	GPIOPinConfigure(GPIO_PA0_U0RX);
	GPIOPinConfigure(GPIO_PA1_U0TX);

	//
	// Enable UART0 so that we can configure the clock.
	//
	SysCtlPeripheralEnable(SYSCTL_PERIPH_UART0);

	//
	// Use the internal 16MHz oscillator as the UART clock source.
	//
	UARTClockSourceSet(UART0_BASE, UART_CLOCK_PIOSC);

	//
	// Select the alternate (UART) function for these pins.
	// TODO: change this to select the port/pin you are using.
	//
	GPIOPinTypeUART(GPIO_PORTA_BASE, GPIO_PIN_0 | GPIO_PIN_1);

	//
	// Initialize the UART for console I/O.
	//
	UARTStdioConfig(0, 38400, 16000000);
}

//*****************************************************************************
//
// Configure the I2C0 master and slave and connect them using loopback mode.
//
//*****************************************************************************
int
main(void)
{
	uint32_t pui32DataTx = 0;
	uint32_t pui32DataRx = 0;
	uint32_t ui32Index;

	//
	// Set the clocking to run directly from the external crystal/oscillator.
	// TODO: The SYSCTL_XTAL_ value must be changed to match the value of the
	// crystal on your board.
	//
	SysCtlClockSet(SYSCTL_SYSDIV_1 | SYSCTL_USE_OSC | SYSCTL_OSC_MAIN |
			SYSCTL_XTAL_16MHZ);

	//
	// The I2C0 peripheral must be enabled before use.
	//
	SysCtlPeripheralEnable(SYSCTL_PERIPH_I2C1);

	SysCtlPeripheralEnable(SYSCTL_PERIPH_GPIOA);

	GPIOPinConfigure(GPIO_PA6_I2C1SCL);
	GPIOPinConfigure(GPIO_PA7_I2C1SDA);
	GPIOPinTypeI2CSCL(GPIO_PORTA_BASE, GPIO_PIN_6);
	GPIOPinTypeI2C(GPIO_PORTA_BASE, GPIO_PIN_7);

	I2CMasterInitExpClk(I2C1_BASE, SysCtlClockGet(), false);

	I2CSlaveEnable(I2C1_BASE);

	I2CSlaveInit(I2C1_BASE, SLAVE_ADDRESS);

	I2CMasterSlaveAddrSet(I2C1_BASE, SLAVE_ADDRESS, false);

	InitConsole();

	UARTprintf("I2C Example\n");

	//
	// Indicate the direction of the data.
	//
	UARTprintf("Tranferring from: Master -> Slave\n");

	//
	// Display the data that the I2C1 master is transferring.
	//
	UARTprintf("  Sending: '0x0E'  . . .  ");

	//
	// Place the data to be sent in the data register
	//
	I2CMasterDataPut(I2C1_BASE, 0x0E);

	//
	// Initiate send of data from the master.  Since the loopback
	// mode is enabled, the master and slave units are connected
	// allowing us to receive the same data that we sent out.
	//
	I2CMasterControl(I2C1_BASE, I2C_MASTER_CMD_SINGLE_SEND);

	//
	// Wait until the slave has received and acknowledged the data.
	//
	while(!(I2CSlaveStatus(I2C1_BASE) & I2C_SLAVE_ACT_RREQ))
	{
	}

	//
	// Read the data from the slave.
	//
	pui32DataRx = I2CSlaveDataGet(I2C1_BASE);

	//
	// Wait until master module is done transferring.
	//
	while(I2CMasterBusy(I2C1_BASE))
	{
	}

	//
	// Display the data that the slave has received.
	//
	UARTprintf("Received: '0x%02x'\n", pui32DataRx);

	//
	// Reset receive buffer.
	//
	pui32DataRx = 0;

	//
	// Indicate the direction of the data.
	//
	UARTprintf("\n\nTranferring from: Slave -> Master\n");

	//
	// Modifiy the data direction to true, so that seeing the address will
	// indicate that the I2C Master is initiating a read from the slave.
	//
	I2CMasterSlaveAddrSet(I2C1_BASE, SLAVE_ADDRESS, true);

	//
	// Do a dummy receive to make sure you don't get junk on the first receive.
	//
	I2CMasterControl(I2C1_BASE, I2C_MASTER_CMD_SINGLE_RECEIVE);

	//
	// Dummy acknowledge and wait for the receive request from the master.
	// This is done to clear any flags that should not be set.
	//
	while(!(I2CSlaveStatus(I2C1_BASE) & I2C_SLAVE_ACT_TREQ))
	{
	}

	UARTprintf("  Sending: '0x0E'  . . .  ");

	//
	// Place the data to be sent in the data register
	//
	I2CSlaveDataPut(I2C1_BASE, 0x0E);

	//
	// Tell the master to read data.
	//
	I2CMasterControl(I2C1_BASE, I2C_MASTER_CMD_SINGLE_RECEIVE);

	//
	// Wait until the slave is done sending data.
	//
	while(!(I2CSlaveStatus(I2C1_BASE) & I2C_SLAVE_ACT_TREQ))
	{
	}

	//
	// Read the data from the master.
	//
	pui32DataRx = I2CMasterDataGet(I2C1_BASE);

	//
	// Display the data that the slave has received.
	//
	UARTprintf("Received: '0x%02x'\n", pui32DataRx);

	//
	// Tell the user that the test is done.
	//
	UARTprintf("\nDone.\n\n");

	//
	// Return no errors
	//
	return(0);
}

  • Hello Hong,

    In the code above you are configuring the I2C Slave of theI2C Peripheral. Please remove the following

    I2CSlaveEnable(I2C1_BASE);

    I2CSlaveInit(I2C1_BASE,SLAVE_ADDRESS);

    I2CSlaveDataPut(I2C1_BASE);

    I2CSlaveDataGet(I2C1_BASE);

    and the while loop for I2CSlaveStatus

    Also please do make sure that after doing I2CMasterControl you put the loop

    while(I2CMasterBusy(I2C1_BASE));

    Regards

    Amit

  • Hi Amit, Can I ask what is the steps to read the i2c slave using the tiva? Below is the steps that I've assumed to read from a slave.

    1) Master sent the device address to read from with write cmd.

    I2CMasterSlaveAddrSet(I2C1_BASE, SLAVE_ADDRESS, false);

    2) Master sent the register to read from. Slave should also send a AK right?

    I2CMasterDataPut(I2C1_BASE, 0x0E);

    I2CMasterControl(I2C1_BASE, I2C_MASTER_CMD_SINGLE_SEND);

    3) Master sent the device address to read from with read cmd.

    I2CMasterControl(I2C1_BASE, I2C_MASTER_CMD_SINGLE_RECEIVE);

    4) Master receive from slave.

    pui32DataRx = I2CMasterDataGet(I2C1_BASE);

    #include <stdbool.h>
    #include <stdint.h>
    #include "inc/hw_i2c.h"
    #include "inc/hw_memmap.h"
    #include "inc/hw_types.h"
    #include "driverlib/gpio.h"
    #include "driverlib/i2c.h"
    #include "driverlib/pin_map.h"
    #include "driverlib/sysctl.h"
    #include "driverlib/uart.h"
    #include "utils/uartstdio.h"
    //
    //*****************************************************************************
    
    //*****************************************************************************
    //
    // Number of I2C data packets to send.
    //
    //*****************************************************************************
    #define NUM_I2C_DATA 1
    
    //
    //*****************************************************************************
    #define SLAVE_ADDRESS 0x1D
    
    //*****************************************************************************
    //
    // This function sets up UART0 to be used for a console to display information
    // as the example is running.
    //
    //*****************************************************************************
    void
    InitConsole(void)
    {
    	//
    	// Enable GPIO port A which is used for UART0 pins.
    	// TODO: change this to whichever GPIO port you are using.
    	//
    	SysCtlPeripheralEnable(SYSCTL_PERIPH_GPIOA);
    
    	//
    	// Configure the pin muxing for UART0 functions on port A0 and A1.
    	// This step is not necessary if your part does not support pin muxing.
    	// TODO: change this to select the port/pin you are using.
    	//
    	GPIOPinConfigure(GPIO_PA0_U0RX);
    	GPIOPinConfigure(GPIO_PA1_U0TX);
    
    	//
    	// Enable UART0 so that we can configure the clock.
    	//
    	SysCtlPeripheralEnable(SYSCTL_PERIPH_UART0);
    
    	//
    	// Use the internal 16MHz oscillator as the UART clock source.
    	//
    	UARTClockSourceSet(UART0_BASE, UART_CLOCK_PIOSC);
    
    	//
    	// Select the alternate (UART) function for these pins.
    	// TODO: change this to select the port/pin you are using.
    	//
    	GPIOPinTypeUART(GPIO_PORTA_BASE, GPIO_PIN_0 | GPIO_PIN_1);
    
    	//
    	// Initialize the UART for console I/O.
    	//
    	UARTStdioConfig(0, 38400, 16000000);
    }
    
    //*****************************************************************************
    //
    // Configure the I2C0 master and slave and connect them using loopback mode.
    //
    //*****************************************************************************
    int
    main(void)
    {
    	uint32_t pui32DataTx = 0;
    	uint32_t pui32DataRx = 0;
    	uint32_t ui32Index;
    
    	//
    	// Set the clocking to run directly from the external crystal/oscillator.
    	// TODO: The SYSCTL_XTAL_ value must be changed to match the value of the
    	// crystal on your board.
    	//
    	SysCtlClockSet(SYSCTL_SYSDIV_1 | SYSCTL_USE_OSC | SYSCTL_OSC_MAIN |
    			SYSCTL_XTAL_16MHZ);
    
    	//
    	// The I2C0 peripheral must be enabled before use.
    	//
    	SysCtlPeripheralEnable(SYSCTL_PERIPH_I2C1);
    
    	SysCtlPeripheralEnable(SYSCTL_PERIPH_GPIOA);
    
    	GPIOPinConfigure(GPIO_PA6_I2C1SCL);
    	GPIOPinConfigure(GPIO_PA7_I2C1SDA);
    	GPIOPinTypeI2CSCL(GPIO_PORTA_BASE, GPIO_PIN_6);
    	GPIOPinTypeI2C(GPIO_PORTA_BASE, GPIO_PIN_7);
    
    	I2CMasterInitExpClk(I2C1_BASE, SysCtlClockGet(), false);
    
    	I2CMasterSlaveAddrSet(I2C1_BASE, SLAVE_ADDRESS, false);
    
    	InitConsole();
    
    	UARTprintf("I2C Example\n");
    
    	//
    	// Indicate the direction of the data.
    	//
    	UARTprintf("Tranferring from: Master -> Slave\n");
    
    	//
    	// Display the data that the I2C1 master is transferring.
    	//
    	UARTprintf("  Sending: '0x0E'  . . .  ");
    
    	//
    	// Place the data to be sent in the data register
    	//
    	I2CMasterDataPut(I2C1_BASE, 0x0E);
    
    	//
    	// Initiate send of data from the master.
    	//
    	I2CMasterControl(I2C1_BASE, I2C_MASTER_CMD_SINGLE_SEND);
    
    	//
    	// Wait until master module is done transferring.
    	//
    	while(I2CMasterBusy(I2C1_BASE))
    	{
    	}
    
    	//
    	// Modifiy the data direction to true, so that seeing the address will
    	// indicate that the I2C Master is initiating a read from the slave.
    	//
    	I2CMasterSlaveAddrSet(I2C1_BASE, SLAVE_ADDRESS, true);
    
    	//
    	// Do a dummy receive to make sure you don't get junk on the first receive.
    	//
    	I2CMasterControl(I2C1_BASE, I2C_MASTER_CMD_SINGLE_RECEIVE);
    
    	//
    	// Tell the master to read data.
    	//
    	I2CMasterControl(I2C1_BASE, I2C_MASTER_CMD_SINGLE_RECEIVE);
    
    	//
    	// Read the data from the master.
    	//
    	pui32DataRx = I2CMasterDataGet(I2C1_BASE);
    
    	//
    	// Display the data that the slave has received.
    	//
    	UARTprintf("Received: '0x%02x'\n", pui32DataRx);
    
    	//
    	// Tell the user that the test is done.
    	//
    	UARTprintf("\nDone.\n\n");
    
    	//
    	// Return no errors
    	//
    	return(0);
    }
    

  • Hello Hong

    After Step-2 and Before Ste-3 you need to do the following step.

    while(I2CMasterBusy(I2C1_BASE));

    Similarly, After step-3 and before step-4

    while(I2CMasterBusy(I2C1_BASE));

    Basically after every I2CMasterControl API Call you need to do while(I2CMasterBusy(I2C1_BASE));

    This ensures that the I2C Master has processed the command.

    Regards

    Amit

  • Hi amit, I did what you suggested, results returning is 0x00, which means it is not really reading anything. I was reading that I need to setup the slave device before i can read it. am i missing something important from my code?

    This is what i got from my logic analyser. from what i see, i'm sending to the correct device address and commands, but just not receiving what i am expecting.

  • Hello Hong,

    After selecting the Address a Repeated Start Needs to be done, while the scope plot shows that a Stop and Start are being done. Hopefully this should help

    Also the Device Register Address must be 0x0D and not 0x0E that was in the original code.

        I2CMasterSlaveAddrSet(I2C1_BASE, SLAVE_ADDRESS, false);
        I2CMasterDataPut(I2C1_BASE, 0x0D);
        //
        // Initiate send of data from the master.
        //
        I2CMasterControl(I2C1_BASE, I2C_MASTER_CMD_BURST_SEND_START);
        //
        // Wait until master module is done transferring.
        //
        while(I2CMasterBusy(I2C1_BASE))
        {
        }
        //
        // Modifiy the data direction to true, so that seeing the address will
        // indicate that the I2C Master is initiating a read from the slave.
        //
        I2CMasterSlaveAddrSet(I2C1_BASE, SLAVE_ADDRESS, true);
        //
        // Do a dummy receive to make sure you don't get junk on the first receive.
        //
        I2CMasterControl(I2C1_BASE, I2C_MASTER_CMD_SINGLE_RECEIVE);
        //
        // Poll for Command Completion
        //
        while(I2CMasterBusy(I2C1_BASE));
        //
        // Read the data from the master.
        //
        pui32DataRx = I2CMasterDataGet(I2C1_BASE);

    Regards

    Amit

  • Hi Amit, I've gotten it to work. thank you very much. I'm not sure if i get you with the repeat start. doesn't I2CMasterSlaveAddrSet(I2C1_BASE, SLAVE_ADDRESS, true); means it will be a repeat start? i will also keep this thread here if i run into any problems when i want to read the data.

  • Hello Hong,

    The Start, Stop and Repeated Start conditions are decided by the command in the I2CMasterControl API call. When it is called with I2C_MASTER_CMD_SINGLE_SEND, then a Start condition is put followed by Address and one data byte after which a Stop condition is put.

    You can look at the Command Table along with I2CMCS register description in the data sheet. It will tell exactly which condition causes what type of transfer on the bus.

    Regards

    Amit

  • Hi amit, do you mind giving a example illustration, because i don't quite get what you mean.

    this is my sequence on how to read from a slave if i get you correctly.

    I2CMasterSlaveAddrSet(I2C1_BASE, SLAVE_ADDRESS, false);

    I2CMasterDataPut(I2C1_BASE, 0xE5);

    I2CMasterControl(I2C1_BASE, I2C_MASTER_CMD_BURST_SEND_START);

    while(I2CMasterBusy(I2C1_BASE));

    I2CMasterControl(I2C1_BASE,I2C_MASTER_CMD_BURST_SEND_FINISH);

    while(I2CMasterBusy(I2C1_BASE));

    I2CMasterSlaveAddrSet(I2C1_BASE, SLAVE_ADDRESS, true);

    I2CMasterControl(I2C1_BASE,I2C_MASTER_CMD_BURST_RECEIVE_START);

    while(I2CMasterBusy(I2C1_BASE));

    for(ui32Index=0; ui32Index<3; ui32Index++) {

        I2CMasterControl(I2C1_BASE,I2C_MASTER_CMD_BURST_RECEIVE_CONT);

        while(!I2CMasterBusy(I2C1_BASE));

        pui32DataRx[ui32Index] = I2CMasterDataGet(I2C1_BASE);

    }

    I2CMasterControl(I2C1_BASE,I2C_MASTER_CMD_BURST_RECEIVE_FINISH);

    while(!I2CMasterBusy(I2C1_BASE));

  • Hello Hong,

    The MCS register when written with START and RUN bit set will cause the master to send the Start Condition+Addr+One Data Byte. After this if a START and RUN is again set the same will occur. Onnly when the STOP bit is set will a Stop condition be put on the I2C Bus.

    The above sequence may not work. Why: because for the I2C_MASTER_CMD_BURST_SEND_FINISH to work the I2C master needs a data to be written into the Data Register.

    I2CMasterSlaveAddrSet(I2C1_BASE, SLAVE_ADDRESS, false);

    I2CMasterDataPut(I2C1_BASE, 0xE5);

    I2CMasterControl(I2C1_BASE, I2C_MASTER_CMD_BURST_SEND_START);

    while(I2CMasterBusy(I2C1_BASE));

    I2CMasterControl(I2C1_BASE,I2C_MASTER_CMD_BURST_SEND_FINISH);

    while(I2CMasterBusy(I2C1_BASE));

    Similarly after

    I2CMasterControl(I2C1_BASE,I2C_MASTER_CMD_BURST_RECEIVE_FINISH);

    while(!I2CMasterBusy(I2C1_BASE));

    the CPU must read the data byte from the I2CMDR otherwise it may result in a stale data.

    Regards

    Amit

  • Hi amit, i've done what you suggested and everything seems to work fine now. however, now i'm having issues with reading multiple bytes from a hygrometer, HTU21D. the message is 12-14 bits long with 2 status bits, hence i should be reading 2 bytes, however, i seems to only receive the first byte.

    from what i see, the slave device transmitted 2 bytes of msg, but i only seem to read the first byte.

    http://www.meas-spec.com/downloads/HTU21D.pdf

    //
    // Modifiy the data direction to true, so that seeing the address will
    // indicate that the I2C Master is initiating a read from the slave.
    //
    I2CMasterSlaveAddrSet(I2C1_BASE, SLAVE_ADDRESS, true);

    //
    // Do a dummy receive to make sure you don't get junk on the first receive.
    //
    I2CMasterControl(I2C1_BASE, I2C_MASTER_CMD_SINGLE_RECEIVE);

    //
    // Tell the master to read data.
    //
    I2CMasterControl(I2C1_BASE,I2C_MASTER_CMD_BURST_RECEIVE_START);

    //
    // Wait until master module is done transferring.
    //
    while(I2CMasterBusy(I2C1_BASE));

    for(ui32Index=0; ui32Index<3; ui32Index++) {

        I2CMasterControl(I2C1_BASE,I2C_MASTER_CMD_BURST_RECEIVE_CONT); //possible error here?

        while(!I2CMasterBusy(I2C1_BASE));

        pui32DataRx[ui32Index] = I2CMasterDataGet(I2C1_BASE);

    }

    I2CMasterControl(I2C1_BASE,I2C_MASTER_CMD_BURST_RECEIVE_FINISH);

    while(!I2CMasterBusy(I2C1_BASE));

  • //
    // Modifiy the data direction to true, so that seeing the address will
    // indicate that the I2C Master is initiating a read from the slave.
    //
    I2CMasterSlaveAddrSet(I2C1_BASE, SLAVE_ADDRESS, true);

    //
    // Do a dummy receive to make sure you don't get junk on the first receive.
    //
    I2CMasterControl(I2C1_BASE, I2C_MASTER_CMD_SINGLE_RECEIVE);

    //
    // Tell the master to read data.
    //
    I2CMasterControl(I2C1_BASE,I2C_MASTER_CMD_BURST_RECEIVE_START);

    //
    // Wait until master module is done transferring.
    //
    while(I2CMasterBusy(I2C1_BASE));

    pui32DataRx[0] = I2CMasterDataGet(I2C1_BASE); 

    I BELIEVE YOU WILL NEED TO RECEIVE DATA HERE^^ AS YOU HAVE JUST SENT THE RECEIVE COMMAND. SO THE  YOU AREN'T READING THE DATA AT THE RIGHT TIME AND THAT'S WHY I THINK YOU ARE ONLY READING ONE OF THE BYTES. 

    for(ui32Index=0; ui32Index<3; ui32Index++) {

        I2CMasterControl(I2C1_BASE,I2C_MASTER_CMD_BURST_RECEIVE_CONT); //possible error here?

        while(!I2CMasterBusy(I2C1_BASE));

        pui32DataRx[ui32Index] = I2CMasterDataGet(I2C1_BASE); 

    }

    THERE IS NO NEED FOR THE LOOP AS YOU ARE ONLY READING TWO BYTES?? 

    I2CMasterControl(I2C1_BASE,I2C_MASTER_CMD_BURST_RECEIVE_FINISH);

    while(!I2CMasterBusy(I2C1_BASE));

    pui32DataRx[1] = I2CMasterDataGet(I2C1_BASE); 

     YOU WILL NEED TO READ DATA AGAIN HERE^^ EDIT: AS AFTER YOU READ THE SECOND BYTE YOU NEED TO SEND THE STOP CONDITION WHICH IS DONE USING I2C_MASTER_CMD_BURST_RECEIVE_FINISH

  • Thanks Alex.

    Now that that is solved, I'm getting another issue. I'm attempting to read from xyz from a mma8452q accelerometer, http://www.freescale.com/files/sensors/doc/data_sheet/MMA8452Q.pdf. I'm able to read the WHO_AM_I register, and I've also set it up to read the xyz with auto increment to next register. However, I seem to be reading the same output no matter how I tilt the accelerometer. Below is the code, waveform and results. 

    Output: 00'8c'03'bc'f6'80'

    		I2CMasterSlaveAddrSet(I2C1_BASE, ACCE_SLAVE_ADDRESS, false);
    
    		//
    		// Place the data to be sent in the data register
    		//
    		I2CMasterDataPut(I2C1_BASE, 0x01);
    
    		//
    		// Initiate send of data from the master.
    		//
    		I2CMasterControl(I2C1_BASE, I2C_MASTER_CMD_BURST_SEND_START);
    
    		//
    		// Wait until master module is done transferring.
    		//
    		while(I2CMasterBusy(I2C1_BASE));
    
    		//
    		// Modifiy the data direction to true, so that seeing the address will
    		// indicate that the I2C Master is initiating a read from the slave.
    		//
    		I2CMasterSlaveAddrSet(I2C1_BASE, ACCE_SLAVE_ADDRESS, true);
    
    		//
    		// Tell the master to read data.
    		//
    		I2CMasterControl(I2C1_BASE, I2C_MASTER_CMD_BURST_RECEIVE_START);
    
    		//
    		// Wait until master module is done transferring.
    		//
    		while(I2CMasterBusy(I2C1_BASE));
    
    		acce_pui8DataRx[0] = I2CMasterDataGet(I2C1_BASE);
    
    		for(ui32Index=0; ui32Index<(ACCE_NUM_I2C_DATA-2); ui32Index++) {
    
    			I2CMasterControl(I2C1_BASE,I2C_MASTER_CMD_BURST_RECEIVE_CONT);
    
    			while(I2CMasterBusy(I2C1_BASE));
    
    			acce_pui8DataRx[ui32Index + 1] = I2CMasterDataGet(I2C1_BASE);
    
    		}
    
    		I2CMasterControl(I2C1_BASE,I2C_MASTER_CMD_BURST_RECEIVE_FINISH);
    
    		while(I2CMasterBusy(I2C1_BASE));
    
    		acce_pui8DataRx[5] = I2CMasterDataGet(I2C1_BASE);

  • nvm, i got it working now. i didn't put the device to active mode.