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.

Blink a led with EK-TM4C123GXL

Other Parts Discussed in Thread: EK-TM4C123GXL

Hi.

I try to make a code that must blink a led, but i receive some errors (see attache.).

 

This is my code :

#include <stdint.h>
#include <stdbool.h>
#include "inc/hw_memmap.h"
#include "inc/hw_types.h"
#include "driverlib/debug.h"
#include "driverlib/gpio.h"
#include "driverlib/fpu.h"
#include "driverlib/pin_map.h"
#include "driverlib/sysctl.h"
#include "driverlib/systick.h"
#include "driverlib/rom.h"
#include "driverlib/uart.h"
#include "utils/uartstdio.h"

static volatile uint32_t g_ui32Value;						// The value that is to be modified via bit-banding.

#ifdef DEBUG
void
__error__(char *pcFilename, uint32_t ui32Line)
{
    while(1)
    {
        UARTprintf("Error at line %d of %s\n", ui32Line, pcFilename);
    }
}
#endif

// Delay for the specified number of seconds.
// Depending upon the current SysTick value, the delay will be between N-1 and N seconds.

void Delay(uint32_t ui32Seconds)
{
    while(ui32Seconds--)
    {
        while(ROM_SysTickValueGet() > 1000)					// Wait until the SysTick value is less than 1000.
        {

        }

        while(ROM_SysTickValueGet() < 1000)					// Wait until the SysTick value is greater than 1000.
        {

        }
    }
}

void ConfigureUART(void)									// Configure the UART and its pins. This must be called before UARTprintf().
{
    ROM_SysCtlPeripheralEnable(SYSCTL_PERIPH_GPIOA);		// Enable the GPIO Peripheral used by the UART.

    ROM_SysCtlPeripheralEnable(SYSCTL_PERIPH_UART0);		// Enable UART0

    ROM_GPIOPinConfigure(GPIO_PA0_U0RX);					// Configure GPIO Pins for UART mode.
    ROM_GPIOPinConfigure(GPIO_PA1_U0TX);
    ROM_GPIOPinTypeUART(GPIO_PORTA_BASE, GPIO_PIN_0 | GPIO_PIN_1);

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

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

int main(void)												// This example demonstrates the use of bit-banding to set individual bits within a word of SRAM.
{
    uint32_t ui32Errors, ui32Idx;

    ROM_FPULazyStackingEnable();					// Enable lazy stacking for interrupt handlers.
    												// This allows floating-point instructions to be used within interrupt handlers, but at the expense of extra stack usage.

    ROM_SysCtlClockSet(SYSCTL_SYSDIV_1 | SYSCTL_USE_OSC | SYSCTL_OSC_MAIN | SYSCTL_XTAL_16MHZ);			// Set the clocking to run directly from the crystal.

    ConfigureUART();																					// Initialize the UART interface.

    UARTprintf("\033[2JBit banding...\n");

    ROM_SysTickPeriodSet(ROM_SysCtlClockGet());				// Set up and enable the SysTick timer. The SysTick timer period will be set up for one second.
    ROM_SysTickEnable();

    g_ui32Value = 0;										// Set the value and error count to zero.
    ui32Errors = 0;

    UARTprintf("\r%08x", g_ui32Value);						// Print the initial value to the UART.

    Delay(1);

    for(ui32Idx = 0; ui32Idx < 32; ui32Idx++)				// Set the value to 0xdecafbad using bit band accesses to each individual bit.
    {
        HWREGBITW(&g_ui32Value, 31 - ui32Idx) = (0xdecafbad >> (31 - ui32Idx)) & 1;				// Set this bit.

        UARTprintf("\r%08x", g_ui32Value);														// Print the current value to the UART.

        Delay(1);
    }

    if(g_ui32Value != 0xdecafbad)							// Make sure that the value is 0xdecafbad.
    {
        ui32Errors++;
    }

    for(ui32Idx = 0; ui32Idx < 32; ui32Idx++)				// Make sure that the individual bits read back correctly.
    {
        if(HWREGBITW(&g_ui32Value, ui32Idx) != ((0xdecafbad >> ui32Idx) & 1))
        {
            ui32Errors++;
        }
    }

    if(ui32Errors)											// Print out the result.
    {
        UARTprintf("\nErrors!\n");
    }
    else
    {
        UARTprintf("\nSuccess!\n");
    }

    while(1)
    {

    }
}

  • Hello Dragu,

    Have you defined the compile time define TARGET_IS_TM4C123_RB1?

    Regards
    Amit
  • Hi Amit,

    As this issue occurs so often - and impacts so many - perhaps better high-lighting (i.e. emphasis) is required...

    Repeated issues signal that the (present) methods/description/alerts are insufficient...   Hope and/or suggest that this issue be promoted to some scheduled, "fix."

  • Hi Amit,

    Mean while i resolved this issue, but now i have the same problem with another project.
    I made the same steps but when i try to make debugging don't works. And, yes i have defined TARGET_IS _TM4C123_RB1.
    Still don't works.
  • DRAGU MIRCEA said:
    I made the same steps but when i try to make debugging don't works. And, yes i have defined TARGET_IS _TM4C123_RB1.
    Still don't work

     I Dragu, which issue are you experiencing? Code to blink a led as from titile is not present on your code, your code is writing to UART but not to GPIO.

     Code doesn't execute, error are at linker level so no executable was built.

     Which platform are you using OS and target board is the one of title?

     Project is build from scratch or imported as on instruction?

     Are all library and setting of IDE correct?

     DO a copy and paste of error than post a microscopic picture.

  • Oh, you are right, sorry Roberto. I have started many projects in the same time and it looks like i posted wrong. The project Blink a led i have abandoned.

    In this moment  i work at another project. I try to make the same thing what the example project (bitband) make with some small modifications.

    But strange i receive the exactly same errors. It seems that the .obj file is not found. I use Windows 7 OS, and the board is Tiva C Series LaunchPad

    EK-TM4C123GXL.

    Sorry again for my awkwardness.

    And this is the code : 

    #include <stdint.h>
    #include <stdbool.h>
    #include "inc/hw_memmap.h"
    #include "inc/hw_types.h"
    #include "driverlib/debug.h"
    #include "driverlib/gpio.h"
    #include "driverlib/fpu.h"
    #include "driverlib/pin_map.h"
    #include "driverlib/sysctl.h"
    #include "driverlib/systick.h"
    #include "driverlib/rom.h"
    #include "driverlib/uart.h"
    #include "utils/uartstdio.h"
    
    static volatile uint32_t bit_banding_value_1, bit_banding_value_2, bit_banding_value_3;			// The values that is to be modified via bit-banding.
    
    #ifdef DEBUG
    void
    __error__(char *pcFilename, uint32_t ui32Line)
    {
        while(1)
        {
    
        }
    }
    #endif
    
    // Delay for the specified number of seconds.
    // Depending upon the current SysTick value, the delay will be between N-1 and N seconds.
    
    void Delay(uint32_t sec_Delay)
    {
        while(sec_Delay--)
        {
            while(ROM_SysTickValueGet() > 1000)					// Wait until the SysTick value is less than 1000.
            {
    
            }
    
            while(ROM_SysTickValueGet() < 1000)					// Wait until the SysTick value is greater than 1000.
            {
    
            }
        }
    }
    
    void ConfigureUART(void)									// Configure the UART and its pins. This must be called before UARTprintf().
    {
        ROM_SysCtlPeripheralEnable(SYSCTL_PERIPH_GPIOA);		// Enable the GPIO Peripheral used by the UART.
    
        ROM_SysCtlPeripheralEnable(SYSCTL_PERIPH_UART0);		// Enable UART0
    
        ROM_GPIOPinConfigure(GPIO_PA0_U0RX);					// Configure GPIO Pins for UART mode.
        ROM_GPIOPinConfigure(GPIO_PA1_U0TX);
        ROM_GPIOPinTypeUART(GPIO_PORTA_BASE, GPIO_PIN_0 | GPIO_PIN_1);
    
        UARTClockSourceSet(UART0_BASE, UART_CLOCK_PIOSC);		// Use the internal 16MHz oscillator as the UART clock source.
    
        UARTStdioConfig(0, 115200, 16000000);					// Initialize the UART for console I/O.
    }
    
    int main(void)												// This example demonstrates the use of bit-banding to set individual bits within a word of SRAM.
    {
        uint32_t errors_1, errors_2, errors_3;
    
        ROM_FPULazyStackingEnable();					// Enable lazy stacking for interrupt handlers.
        												// This allows floating-point instructions to be used within interrupt handlers, but at the expense of extra stack usage.
    
        ROM_SysCtlClockSet(SYSCTL_SYSDIV_1 | SYSCTL_USE_OSC | SYSCTL_OSC_MAIN | SYSCTL_XTAL_16MHZ);			// Set the clocking to run directly from the crystal.
    
        ConfigureUART();																					// Initialize the UART interface.
    
        UARTprintf("\033[2JBit banding...\n");
    
        ROM_SysTickPeriodSet(ROM_SysCtlClockGet());				// Set up and enable the SysTick timer. The SysTick timer period will be set up for one second.
        ROM_SysTickEnable();
    
        bit_banding_value_1 = 0;								// Set the value and error count to zero.
        bit_banding_value_2 = 0;
        bit_banding_value_3 = 0;
        errors_1 = 0;
        errors_2 = 0;
        errors_3 = 0;
    
        Delay(1);
    
        HWREGBITW(&bit_banding_value_1, 31) = (0x01 >> 31) & 1;							// Set this bit.
        HWREGBITW(&bit_banding_value_1, 15) = (0x01 >> 15) & 1;
        UARTprintf("\r%08x", bit_banding_value_1);
    
        Delay(1);
    
        HWREGBITW(&bit_banding_value_2, 10) = (0x01 >> 10) & 1;
        HWREGBITW(&bit_banding_value_2, 9) = (0x01 >> 9) & 1;
        UARTprintf("\r%08x", bit_banding_value_2);
    
        Delay(1);
    
        HWREGBITW(&bit_banding_value_3, 3) = (0x01 >> 3) & 1;
        HWREGBITW(&bit_banding_value_3, 2) = (0x01 >> 2) & 1;
        HWREGBITW(&bit_banding_value_3, 1) = (0x01 >> 1) & 1;
        HWREGBITW(&bit_banding_value_3, 0) = (0x01 >> 0) & 1;
        UARTprintf("\r%08x", bit_banding_value_3);
    
        Delay(1);
    
        if(bit_banding_value_1 && (1 << 31)!= 0x01 && bit_banding_value_1 && (1 << 15)!= 0x01)		// Make sure that the bits is set.
        {
            errors_1++;
        }
    
        if(bit_banding_value_2 && (1 << 10)!= 0x01 && bit_banding_value_2 && (1 << 9)!= 0x01)		// Make sure that the bits is sets.
        {
            errors_2++;
        }
    
        if(bit_banding_value_3 && (1 << 3)!= 0x01 && bit_banding_value_3 && (1 << 2)!= 0x01 && bit_banding_value_3 && (1 << 1)!= 0x01 && bit_banding_value_3 && (1 << 0)!= 0x01)
    
        {
            errors_3++;
        }
    
        if(HWREGBITW(&bit_banding_value_1, 31) != ((0x01 >> 31) & 1) && HWREGBITW(&bit_banding_value_1, 15) != ((0x01 >> 15) & 1))
        {
            errors_1++;
        }
    
        if(HWREGBITW(&bit_banding_value_2, 10) != ((0x01 >> 10) & 1) && HWREGBITW(&bit_banding_value_2, 9) != ((0x01 >> 9) & 1))
        {
            errors_2++;
        }
    
        if(HWREGBITW(&bit_banding_value_3, 3) != ((0x01 >> 3) & 1) && HWREGBITW(&bit_banding_value_3, 2) != ((0x01 >> 2) & 1) && \
        			HWREGBITW(&bit_banding_value_3, 1) != ((0x01 >> 1) & 1) && HWREGBITW(&bit_banding_value_3, 0) != ((0x01 >> 0) & 1))
        {
            errors_3++;
        }
    
        if(errors_1)												// Print out the result.
        {
            UARTprintf("\nErrors!\n");
        }
        else
        {
            UARTprintf("\nSuccess!\n");
        }
    
        if(errors_2)												// Print out the result.
        {
            UARTprintf("\nErrors!\n");
        }
        else
        {
            UARTprintf("\nSuccess!\n");
        }
    
        if(errors_3)												// Print out the result.
        {
            UARTprintf("\nErrors!\n");
        }
        else
        {
            UARTprintf("\nSuccess!\n");
        }
    
        while(1)
        {
    
        }
    }
    

  • Hello Dragu,

    You have not added include "driverlib/interrupt.h"

    Regards
    Amit
  • DRAGU MIRCEA said:

    In this moment  i work at another project. I try to make the same thing what the example project (bitband) make with some small modifications.

    But strange i receive the exactly same errors. It seems that the .obj file is not found. I use Windows 7 OS, and the board is Tiva C Series LaunchPad

     Hi Dragu, to get faster solution, please don't post more code listing nor images of ide, make instead a compressed image of directory project then send as FILE.

     click "reply button"  then use "rich editor" on low right , click on middle of editor "Insert file". Someone here can see what is wrong. I think some setting or file are missing.

  • Hello Amit,

    No, is not about that. I have tried with this header file and don't work.
    I don't know why this issue is present on my many projects.
    On the example project i don't have this issue.
    I don't know what i supposed to do.
    Thank you for your interest.

    OK, Roberto I understood.
    Thank you for your interest also.

    Regards
    Mircea
  • Hello Mircea,

    I went through the code and snapshot. I can summarize a few things

    1. If the board is EK-TM4C123 then why is the define TARGET_IS_TM4C123_RA1? It should be TARGET_IS_TM4C123_RB1
    2. The header file inclusion is a must for the compiler to know that the function indeed exists.
    3. Instead of using the SW_ROOT use the absolute path for the include and driverlib.
    4. In the error log snapshot can, you instead take a snapshot of the parameters-options being parsed to the compiler and linker.

    Regards
    Amit