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.

TM4C1294KCPDT: TM4C1294 EVK

Part Number: TM4C1294KCPDT

Hi Team,

Iam trying to up the Ethernet communication in TM4C1294 EVK (Free RTOS + LWIP), So I use the demo code enet_tcpecho_client_lwip (without Free RTOS), 

So I tried to integrate the Free RTOS with ethernet receive and transmit task, but iam getting struck with my code in connection establishment stage.

I just need a demo project with (Free RTOS + LWIP + TM4C1294 EVK + Ethernet client transmit and Receive task) , so that i can try to identify the API steps and try to fix the issue

currently Iam using the following projects but there is not demo project with FREE RTOS

Do the needful to resolve the issue

 

  • Hi,

    I just need a demo project with (Free RTOS + LWIP + TM4C1294 EVK + Ethernet client transmit and Receive task) , so that i can try to identify the API steps and try to fix the issue

    Sorry, we don't have such a project with Free RTOS + LWIP + TM4C1294 EVK + Ethernet client transmit and Receive task for TM4C129. The non-rtos raw enet_tcpecho_client_lwip is the only client example we have for lwIP. 

  • hi team

    Can you please provide us with the I2c code for TM4c1294 EVK as we could not see any clock initialization in our code ,please correct us if any change needs to be done in our code .
    please revert back asap.
  • //============================================================================
    // Name        : i2cAPI.c
    // Author      :
    // Version     :
    // Copyright   : Your copyright notice
    // Description : Tiva i2c in C++, Ansi-style
    //============================================================================
    /*
     * i2cAPI.c
     * Implementation of a i2c interface
     *
     * Copyright
     *
     * Redistribution and use in source and binary forms, with or without modification,
     * are permitted provided that the following conditions are met:
     * 1. Redistributions of source code must retain the above copyright
     *    notice, this list of conditions and the following disclaimer.
     * 2. Redistributions in binary form must reproduce the above copyright
     *    notice, this list of conditions and the following disclaimer in the
     *    documentation and/or other materials provided with the distribution.
     *
     * THIS SOFTWARE IS PROVIDED ''AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES,
     * INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY
     * AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL I
     * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
     * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE
     * GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
     * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
     * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
     * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
     */
    
    
    #include <stdint.h>
    #include <stdio.h>
    #include <stdbool.h>
    #include "i2cAPI.h"
    #include "driverlib/inc/tm4c1294kcpdt.h"
    #include "driverlib/inc/hw_i2c.h"
    #include "driverlib/inc/hw_memmap.h"
    #include "driverlib/inc/hw_types.h"
    #include "driverlib/inc/hw_gpio.h"
    #include "driverlib/i2c.h"
    #include "driverlib/sysctl.h"
    #include "driverlib/gpio.h"
    #include "driverlib/pin_map.h"
    #include "driverlib/rom_map.h"
    #include "utils/uartstdio.h"
    
    uint32_t i2c_init(uint32_t g_ui32SysClock)
    {
    	//This function is for eewiki and is to be updated to handle any port
        //  Enable peripherals in use. Also reset I2C2 at the end to allow calling
            //  this function at any point in order to reset I2C interface.
            MAP_SysCtlPeripheralEnable(SYSCTL_PERIPH_GPIOD);
    
            MAP_SysCtlPeripheralEnable(SYSCTL_PERIPH_I2C8);
    
    
            // Enable I2C communication interface, SCL, SDA lines
            MAP_GPIOPinConfigure(GPIO_PD2_I2C8SCL);
            MAP_GPIOPinConfigure(GPIO_PD3_I2C8SDA);
    
            MAP_GPIOPinTypeI2CSCL(GPIO_PORTD_BASE, GPIO_PIN_2);
            MAP_GPIOPinTypeI2C(GPIO_PORTD_BASE, GPIO_PIN_3);
    
            //  Enable I2C master interface
            MAP_I2CMasterEnable(I2C8_BASE);
    
            // Run I2C bus in high-speed mode, 400kHz speed
            MAP_I2CMasterInitExpClk(I2C8_BASE, g_ui32SysClock, true);
    
    
    
    
    	/*//enable GPIO peripheral that contains I2C
    	SysCtlPeripheralEnable(SYSCTL_PERIPH_GPIOD);
    
    	while(!SysCtlPeripheralReady(SYSCTL_PERIPH_GPIOD))
        {
            UARTprintf("I2c master busy Init\r\n");
            break;
        }
    
    	// Configure the pin muxing for I2C0 functions on port B2 and B3.
    	GPIOPinConfigure(GPIO_PD2_I2C8SCL);
    	GPIOPinConfigure(GPIO_PD3_I2C8SDA);
    
    	// Select the I2C function for these pins.
    	GPIOPinTypeI2CSCL(GPIO_PORTD_BASE, GPIO_PIN_2);
    	GPIOPinTypeI2C(GPIO_PORTD_BASE, GPIO_PIN_3);
    	//I2CMasterEnable( I2C8_BASE );
    	// Enable and initialize the I2C0 master module.  Use the system clock for
    	// the I2C0 module.  The last parameter sets the I2C data transfer rate.
    	// If false the data rate is set to 100kbps and if true the data rate will
    	// be set to 400kbps.
    	//I2CMasterInitExpClk(I2C8_BASE, SysCtlClockGet(), false);
    	SysCtlPeripheralDisable(SYSCTL_PERIPH_I2C8);
    	SysCtlPeripheralReset(SYSCTL_PERIPH_I2C8);
    	SysCtlPeripheralEnable(SYSCTL_PERIPH_I2C8);
    
    	while(!SysCtlPeripheralReady(SYSCTL_PERIPH_GPIOD))
        {
            UARTprintf("I2c master busy Init_1\r\n");
            break;
        }
    
    	I2CMasterInitExpClk(I2C8_BASE, g_ui32SysClock, true);
    */
    
    	//clear I2C FIFOs
    	/*HWREG(I2C8_BASE + I2C_O_FIFOCTL) = 80008000;*/
    }
    
    void i2c_read_byte(uint16_t device_address, uint16_t device_register, uint8_t *pui32DataRx)
    {
        i2c_read_multi(device_address,device_register,pui32DataRx,1);
    }
    
    void i2c_write_byte(uint16_t device_address, uint16_t device_register, uint8_t pui32DataTx)
    {
        uint8_t ui8DataTx = pui32DataTx;
        i2c_write_multi(device_address,device_register,&ui8DataTx,1);
    }
    
    void i2c_read_multi(uint16_t device_address, uint16_t device_register, uint8_t *pui32DataRx,uint8_t nNumbytes)
    {
        uint32_t I2cbaseregAddr = I2C0_BASE;
    	//specify that we want to communicate to device address with an intended write to bus
    	I2CMasterSlaveAddrSet(I2cbaseregAddr, device_address, false);
    
    	//the register to be read
    	I2CMasterDataPut(I2cbaseregAddr, device_register);
    
    	//send control byte and register address byte to slave device
    	I2CMasterControl(I2cbaseregAddr, I2C_MASTER_CMD_SINGLE_SEND);
    
    	//wait for MCU to complete send transaction
    	while(I2CMasterBusy(I2cbaseregAddr))
        {
    	    UARTprintf("I2c master busy\r\n");
        }
    
    	//read from the specified slave device
    	I2CMasterSlaveAddrSet(I2cbaseregAddr, device_address, true);
    
    	//send control byte and read from the register from the MCU
    	I2CMasterControl(I2cbaseregAddr, I2C_MASTER_CMD_SINGLE_RECEIVE);
    
    	//wait while checking for MCU to complete the transaction
    	while(I2CMasterBusy(I2cbaseregAddr))
    	{
    	    UARTprintf("I2c master busy\r\n");
    	}
    
    
        // 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(I2cbaseregAddr) & I2C_SLAVE_ACT_TREQ))
        {
        }
    
    	if(nNumbytes == 1)
    	{
    	    pui32DataRx[nNumbytes] = I2CMasterDataGet(I2cbaseregAddr);
    	}
    	else if(nNumbytes > 1)
    	{
    	    for(ui32Index = 0; ui32Index < nNumbytes; ui32Index++)
            {
                //
                // Read the data from the master.
                //
                pui32DataRx[ui32Index] = I2CMasterDataGet(I2cbaseregAddr);
    
                //
                // Display the data that the slave has received.
                //
                //UARTprintf("Received: '%c'\n", pui32DataRx[ui32Index]);
            }
    
    	}
    }
    
    void i2c_write_multi(uint16_t device_address, uint16_t device_register, uint8_t* pui32DataTx,uint8_t nNumbytes)  //uint32_t pui32DataTx[NUM_I2C_DATA];
    {
        uint32_t I2cbaseregAddr = I2C0_BASE;
    	//specify that we want to communicate to device address with an intended write to bus
    	I2CMasterSlaveAddrSet(I2cbaseregAddr, device_address, false);
    
    	//register to be read
    	I2CMasterDataPut(I2cbaseregAddr, device_register);
    
    	//send control byte and register address byte to slave device
    	I2CMasterControl(I2cbaseregAddr, I2C_MASTER_CMD_BURST_SEND_START);
    
    	//wait for MCU to finish transaction
    	while(I2CMasterBusy(I2cbaseregAddr));
    
    	I2CMasterSlaveAddrSet(I2cbaseregAddr, device_address, true);
    
    	//specify data to be written to the above mentioned device_register
    	while(nNumbytes--)
    	{
            //
            // Place the data to be sent in the data register
            //
    	    I2CMasterDataPut(I2cbaseregAddr, pui32DataTx);
    	    UARTprintf("  Sending: '%c'  . . .  ", pui32DataTx);
            //
            // 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(I2cbaseregAddr, I2C_MASTER_CMD_SINGLE_SEND);
    
    	    //
    	    // Wait until the slave has received and acknowledged the data.
    	    //
    	    while(!(I2CSlaveStatus(I2cbaseregAddr) & I2C_SLAVE_ACT_RREQ))
            {
    	       UARTprintf("I2c NACK\r\n");
            }
    
    	    pui32DataTx++;
    	}
    	//wait while checking for MCU to complete the transaction
    	I2CMasterControl(I2cbaseregAddr, I2C_MASTER_CMD_BURST_RECEIVE_FINISH);
    
    	//wait for MCU & device to complete transaction
    	while(I2CMasterBusy(I2cbaseregAddr));
    	{
    	    UARTprintf("I2c master busy\r\n");
    	}
    
    }
    

  • Several questions:

     - Between line 52-71, you initialize I2C8. But between 76-108, you initialize I2C8 again. Why are you doing so? 

     - In your line 128 and 188, you hard code I2C0. I thought you wanted to use I2C8 as you initiate I2C8 in i2c_init(). If you want to use I2C0, where is your initialization for I2C0? This is why it does not work. 

     - Make sure you have proper pullup for SDA and SDL on you board for whichever I2C bus (e.g. I2C8SDA and I2C8SCL) you want to use. 

     BTW, if you have a new question about I2C, you should open a new thread for discussion. You don't just reject my answer two weeks ago regarding Ethernet.