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.

TM4C129XNCZAD: Getting started with TM4C129XNCZAD

Part Number: TM4C129XNCZAD
Other Parts Discussed in Thread: EK-TM4C1294XL

Hi all im just starting with TM4C129XNCZAD im trying to blink a port pin for one second to start with, can any one guide me in this can any one give me the code to start with.

  • Hi Nagaraj,

      If you have not downloaded TivaWare, please download TivaWare from https://www.ti.com/tool/SW-TM4C. TivaWare is a software development kit (SDK) that provides all the components necessary for engineers to evaluate and develop applications for the TM4C  device family. Once you download the SDK, you can find many examples under C:\ti\TivaWare_C_Series-2.2.0.295\examples\boards\ek-tm4c1294xl. You can start with the blinky and project0 and hello examples. An blinky example can be as simple as follows. 

    #include <stdint.h>
    #include <stdbool.h>
    #include "inc/hw_memmap.h"
    #include "driverlib/debug.h"
    #include "driverlib/gpio.h"
    #include "driverlib/sysctl.h"
    
    //*****************************************************************************
    //
    //! \addtogroup example_list
    //! <h1>Blinky (blinky)</h1>
    //!
    //! A very simple example that blinks the on-board LED using direct register
    //! access.
    //
    //*****************************************************************************
    
    //*****************************************************************************
    //
    // The error routine that is called if the driver library encounters an error.
    //
    //*****************************************************************************
    #ifdef DEBUG
    void
    __error__(char *pcFilename, uint32_t ui32Line)
    {
        while(1);
    }
    #endif
    
    //*****************************************************************************
    //
    // Blink the on-board LED.
    //
    //*****************************************************************************
    int
    main(void)
    {
        volatile uint32_t ui32Loop;
    
        //
        // Enable the GPIO port that is used for the on-board LED.
        //
        SysCtlPeripheralEnable(SYSCTL_PERIPH_GPION);
    
        //
        // Check if the peripheral access is enabled.
        //
        while(!SysCtlPeripheralReady(SYSCTL_PERIPH_GPION))
        {
        }
    
        //
        // Enable the GPIO pin for the LED (PN0).  Set the direction as output, and
        // enable the GPIO pin for digital function.
        //
        GPIOPinTypeGPIOOutput(GPIO_PORTN_BASE, GPIO_PIN_0);
    
        //
        // Loop forever.
        //
        while(1)
        {
            //
            // Turn on the LED.
            //
            GPIOPinWrite(GPIO_PORTN_BASE, GPIO_PIN_0, GPIO_PIN_0);
    
            //
            // Delay for a bit.
            //
            for(ui32Loop = 0; ui32Loop < 200000; ui32Loop++)
            {
            }
    
            //
            // Turn off the LED.
            //
            GPIOPinWrite(GPIO_PORTN_BASE, GPIO_PIN_0, 0x0);
    
            //
            // Delay for a bit.
            //
            for(ui32Loop = 0; ui32Loop < 200000; ui32Loop++)
            {
            }
        }
    }

    #include <stdint.h>
    #include <stdbool.h>
    #include "inc/hw_types.h"
    #include "inc/hw_memmap.h"
    #include "driverlib/sysctl.h"
    #include "driverlib/gpio.h"
    
    //*****************************************************************************
    //
    // Define pin to LED mapping.
    //
    //*****************************************************************************
    
    //*****************************************************************************
    //
    //! \addtogroup example_list
    //! <h1>Project Zero (project0)</h1>
    //!
    //! This example demonstrates the use of TivaWare to setup the clocks and
    //! toggle GPIO pins to make the LED blink. This is a good place to start
    //! understanding your launchpad and the tools that can be used to program it.
    //
    //*****************************************************************************
    
    #define USER_LED1  GPIO_PIN_0
    #define USER_LED2  GPIO_PIN_1
    
    //*****************************************************************************
    //
    // The error routine that is called if the driver library encounters an error.
    //
    //*****************************************************************************
    #ifdef DEBUG
    void
    __error__(char *pcFilename, uint32_t ui32Line)
    {
    }
    #endif
    
    //*****************************************************************************
    //
    // Main 'C' Language entry point.  Toggle an LED using TivaWare.
    //
    //*****************************************************************************
    int
    main(void)
    {
        uint32_t ui32SysClock;
    
        //
        // Run from the PLL at 120 MHz.
        // Note: SYSCTL_CFG_VCO_240 is a new setting provided in TivaWare 2.2.x and
        // later to better reflect the actual VCO speed due to SYSCTL#22.
        //
        ui32SysClock = SysCtlClockFreqSet((SYSCTL_XTAL_25MHZ |
                                           SYSCTL_OSC_MAIN |
                                           SYSCTL_USE_PLL |
                                           SYSCTL_CFG_VCO_240), 120000000);
    
        //
        // Enable and wait for the port to be ready for access
        //
        SysCtlPeripheralEnable(SYSCTL_PERIPH_GPION);
        while(!SysCtlPeripheralReady(SYSCTL_PERIPH_GPION))
        {
        }
        
        //
        // Configure the GPIO port for the LED operation.
        //
        GPIOPinTypeGPIOOutput(GPIO_PORTN_BASE, (USER_LED1|USER_LED2));
    
        //
        // Loop Forever
        //
        while(1)
        {
            //
            // Turn on the LED
            //
            GPIOPinWrite(GPIO_PORTN_BASE, (USER_LED1|USER_LED2), USER_LED1);
    
            //
            // Delay for a bit
            //
            SysCtlDelay(ui32SysClock/6);
    
            //
            // Turn on the LED
            //
            GPIOPinWrite(GPIO_PORTN_BASE, (USER_LED1|USER_LED2), USER_LED2);
    
            //
            // Delay for a bit
            //
            SysCtlDelay(ui32SysClock/6);
        }
    }

      

  • Thankyou for the support charles I am trying to turn on the port pin high but the port pin is not going high can you please help me out in this i have attached my code snippet along with this message

    #include <stdint.h>
    #include <stdbool.h>
    #include "inc/hw_memmap.h"
    #include "driverlib/debug.h"
    #include "driverlib/gpio.h"
    #include "driverlib/sysctl.h"
    
    //*****************************************************************************
    //
    //! \addtogroup example_list
    //! <h1>Blinky (blinky)</h1>
    //!
    //! A very simple example that blinks the on-board LED using direct register
    //! access.
    //
    //*****************************************************************************
    
    //*****************************************************************************
    //
    // The error routine that is called if the driver library encounters an error.
    //
    //*****************************************************************************
    #ifdef DEBUG
    void
    __error__(char *pcFilename, uint32_t ui32Line)
    {
        while(1);
    }
    #endif
    
    //*****************************************************************************
    //
    // Blink the on-board LED.
    //
    //*****************************************************************************
    int
    main(void)
    {
        volatile uint32_t ui32Loop;
    
        //
        // Enable the GPIO port that is used for the on-board LED.
        //
        SysCtlPeripheralEnable(SYSCTL_PERIPH_GPION);
    
        //
        // Check if the peripheral access is enabled.
        //
        while(!SysCtlPeripheralReady(SYSCTL_PERIPH_GPION))
        {
        }
    
        //
        // Enable the GPIO pin for the LED (PN0).  Set the direction as output, and
        // enable the GPIO pin for digital function.
        //
        GPIOPinTypeGPIOOutput(GPIO_PORTF_BASE, GPIO_PIN_4);
        GPIOPinTypeGPIOOutput(GPIO_PORTE_BASE, GPIO_PIN_6);
    
        //
        // Loop forever.
        //
        while(1)
        {
            //
            // Turn on the LED.
            //
            GPIOPinWrite(GPIO_PORTF_BASE, GPIO_PIN_4, GPIO_PIN_4);
            GPIOPinWrite(GPIO_PORTE_BASE, GPIO_PIN_6, GPIO_PIN_6);
    
    
        }
    }
    
    .

  • Hi,

      If you want to turn on LED that is attached to PF4 or PE6 then you need to first enable these two ports. Currently you only enable PN. You will get an abort if you to try to access portF and portE if they are not first enabled. You need to add below code. 

    //
    // Enable the GPIO port that is used for the on-board LED.
    //
    SysCtlPeripheralEnable(SYSCTL_PERIPH_GPIOF);

    SysCtlPeripheralEnable(SYSCTL_PERIPH_GPIOE);

    //
    // Check if the peripheral access is enabled.
    //
    while(!SysCtlPeripheralReady(SYSCTL_PERIPH_GPIOF))
    {
    }

    while(!SysCtlPeripheralReady(SYSCTL_PERIPH_GPIOE))
    {
    }

  • Thankyou Charles i got the LED blinking now, i have attached my code snippet for reference thankyou.. 

    int main(void)
    {
        volatile uint32_t ui32Loop;
    
        //
        // Enable the GPIO port that is used for the on-board LED.
        //
        SysCtlPeripheralEnable(SYSCTL_PERIPH_GPION);
    
        //
        // Check if the peripheral access is enabled.
        //
        while(!SysCtlPeripheralReady(SYSCTL_PERIPH_GPION))
        {
        }
    
        SysCtlPeripheralEnable(SYSCTL_PERIPH_GPIOF);
    
    
    
        //
        // Check if the peripheral access is enabled.
        //
        while(!SysCtlPeripheralReady(SYSCTL_PERIPH_GPIOF))
        {
        }
        SysCtlPeripheralEnable(SYSCTL_PERIPH_GPIOE);
        while(!SysCtlPeripheralReady(SYSCTL_PERIPH_GPIOE))
        {
        }
    
        //
        // Enable the GPIO pin for the LED (PN0).  Set the direction as output, and
        // enable the GPIO pin for digital function.
        //
        GPIOPinTypeGPIOOutput(GPIO_PORTF_BASE, GPIO_PIN_4);
        GPIOPinTypeGPIOOutput(GPIO_PORTE_BASE, GPIO_PIN_6);
    
        //
        // Loop forever.
        //
        while(1)
        {
            //
            // Turn on the LED.
            //
            GPIOPinWrite(GPIO_PORTF_BASE, GPIO_PIN_4, GPIO_PIN_4);
            GPIOPinWrite(GPIO_PORTE_BASE, GPIO_PIN_6, GPIO_PIN_6);
    
    
            //
            // Delay for a bit.
            //
            for(ui32Loop = 0; ui32Loop < 2000000; ui32Loop++)
            {
            }
    
            //
            // Turn off the LED.
            //
            GPIOPinWrite(GPIO_PORTF_BASE, GPIO_PIN_4, 0x0);
    
            //
            // Delay for a bit.
            //
            for(ui32Loop = 0; ui32Loop < 2000000; ui32Loop++)
            {
            }
        }
    
    	return 0;
    }