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.

TM4C1294 Master Receive

Other Parts Discussed in Thread: MSP430G2553

I am trying to generate a master recieve with the TM4C1294 using the MSP430G2553 as the slave sender. However, I believe I have the slave sender correct but I wanted to double check what address I should use in order to send it to the master. Nonetheless, I am not receiving on the master what I am sending from the slave. I have attached my master recieve code below and a snapshot of the I2C bus.

1261.TM4C1294_I2C_Master_RX.zip

  • Hello Andrew

    The Address being sent to the Slave device is 0x04 as shown in the waveform and as configured in the code. However the Slave is Not Acknowledging the Address being sent to it.

    So clearly it is a Slave problem (unless the Slave Address is not correctly written)

    Regards

    Amit

  • The slave is supposed to be transmitting to the master so does the master receive code look correct? 

  • Hello Andrew,

    Even if the Slave is transmitting to the master, it has to be first selected on the bus. For this Master has to send the Address along with the R/W signal. If the Slave sees it's address it will ACK and only then will it begin transmitting. The code does not seem correct either

    void I2C0MasterRX(unsigned char address)
    {
                //
                // Specify slave address for recieve
                //
                I2CMasterSlaveAddrSet(I2C0_BASE, address, true);

                //
                // Initiate recieve of character from Slave to Master
                //
                I2CMasterControl(I2C0_BASE, I2C_MASTER_CMD_SINGLE_RECEIVE);


                //
                // Wait for recieve to begin
                //
                while(!I2CMasterBusy(I2C0_BASE));
                //
                // Delay until recieve completes
                //
                while(I2CMasterBusy(I2C0_BASE));

                //
                // Get the character that was recieved in the data register
                //
                data = I2CMasterDataGet(I2C0_BASE);

    }

    Regards

    Amit

  • Amit,

    Thank you for your help. I am now able to receive data on the master but obviously I can only receive one byte. My slave is sending "hello" and I tried to modify my master receive code to receive the "h" and "e". Does my code look correct? 

    void I2C0MasterRX(unsigned char address)
    {
    //
    // Specify slave address for recieve
    //
    I2CMasterSlaveAddrSet(I2C0_BASE, address, true);

    //
    // Initiate recieve of character from Slave to Master
    //
    I2CMasterControl(I2C0_BASE, I2C_MASTER_CMD_BURST_RECEIVE_START);
    //
    // Wait for recieve to begin
    //
    while(!I2CMasterBusy(I2C0_BASE));
    //
    // Delay until recieve completes
    //
    while(I2CMasterBusy(I2C0_BASE));
    //
    // Get the character that was recieved in the data register
    //
    data[0] = I2CMasterDataGet(I2C0_BASE);

    //
    // Initiate recieve of character from Slave to Master
    //
    I2CMasterControl(I2C0_BASE, I2C_MASTER_CMD_BURST_RECEIVE_FINISH);
    //
    // Wait for recieve to begin
    //
    while(!I2CMasterBusy(I2C0_BASE));
    //
    // Delay until recieve completes
    //
    while(I2CMasterBusy(I2C0_BASE));
    //
    // Get the character that was recieved in the data register
    //
    data[1] = I2CMasterDataGet(I2C0_BASE);

    }

    Here is a trace of what is being seen on the I2C bus.

  • Hello Andrew,

    To receive the entire sting you need to use

    I2C_MASTER_CMD_BURST_RECEIVE_CONT

    between

    I2C_MASTER_CMD_BURST_RECEIVE_START and I2C_MASTER_CMD_BURST_RECEIVE_FINISH commands. The usage will remain the same and the rest of the code can remain as is

    As an example

    for(ulIdx=1;ulIdx<(N-1);ulIdx++)

    {

    //
    // Receive of character from Slave to Master
    //
    I2CMasterControl(I2C0_BASE, I2C_MASTER_CMD_BURST_RECEIVE_CONT);
    //
    // Wait for recieve to begin
    //
    while(!I2CMasterBusy(I2C0_BASE));
    //
    // Delay until recieve completes
    //
    while(I2CMasterBusy(I2C0_BASE));
    //
    // Get the character that was recieved in the data register
    //
    data[ulIdx] = I2CMasterDataGet(I2C0_BASE);

    }

    In this case N is the total number of bytes. Byte 0 goes with start and Byte N-1 goes with Finish.

    Regards

    Amit

  • Amit,

    I tried the following code and it seems to work sometimes but then other times it receives trash as shown in the screen shots below.

    void I2C0MasterRX(unsigned char address)
    {
    unsigned char i = 0;

    //
    // Specify slave address for recieve
    //
    I2CMasterSlaveAddrSet(I2C0_BASE, address, true);

    //
    // Initiate recieve of character from Slave to Master
    //
    I2CMasterControl(I2C0_BASE, I2C_MASTER_CMD_BURST_RECEIVE_START);
    //
    // Wait for recieve to begin
    //
    while(!I2CMasterBusy(I2C0_BASE));
    //
    // Delay until recieve completes
    //
    while(I2CMasterBusy(I2C0_BASE));
    //
    // Get the character that was recieved in the data register
    //
    data[0] = I2CMasterDataGet(I2C0_BASE);

    for(i=1; i<8; i++)
    {
    //
    // Initiate recieve of character from Slave to Master
    //
    I2CMasterControl(I2C0_BASE, I2C_MASTER_CMD_BURST_RECEIVE_CONT);
    //
    // Wait for recieve to begin
    //
    while(!I2CMasterBusy(I2C0_BASE));
    //
    // Delay until recieve completes
    //
    while(I2CMasterBusy(I2C0_BASE));
    //
    // Get the character that was recieved in the data register
    //
    data[i] = I2CMasterDataGet(I2C0_BASE);
    }

    //
    // Initiate recieve of character from Slave to Master
    //
    I2CMasterControl(I2C0_BASE, I2C_MASTER_CMD_BURST_RECEIVE_FINISH);
    //
    // Wait for recieve to begin
    //
    while(!I2CMasterBusy(I2C0_BASE));
    //
    // Delay until recieve completes
    //
    while(I2CMasterBusy(I2C0_BASE));
    //
    // Get the character that was recieved in the data register
    //
    data[8] = I2CMasterDataGet(I2C0_BASE);

    }

  • Hello Andrew,

    You may need to check if the slave device has some kind of wait time between fetches such that it would not be able to fill the buffer and because of a new transmission request would hold the line till a Stop condition is done on the bus.

    This may be something MSP430 specific so a good idea would be to post it to the MSP430 forum too.,

    Regards

    Amit