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.

EK-TM4C123GXL: Making LED blink

Part Number: EK-TM4C123GXL
Hello, how would I possibly go about testing the LED on the TivaC TM4C123GXL device? I've looked through hours of instruction videos online and the 
documentation to set up the LED blink program but I cannot get this device to work. I downloaded KEIL Uvision V5 and I have the Stellaris ICDI selected in the debugger tab.
I'll post my sample code down below that I found. The LED does come on, but I cannot get it to shut off. I have the drivers installed and I have multiple sample programs
that basically come to the same conclusion, a static LED. I went into the debugger and saw that the DATA register was being toggled on and off when you open
the debug session> system viewer windows drop down list> GPIO>GPIOF, you will see the first box called DATA. When you run the program below you will see that these
two addresses are toggled: 0x00000002 and 0x00000000. This should indicate that the red LED should be turning on and off. But on my board it stays static.
Can anyone help me with this? This code is something I got online to try to get this board working. It seems to be the only one that I found that seems to be blinking
something. I know this is kind of a noob question, but I'm just trying to learn about embedded systems, been fighting with this all weekend, I'm out of resources to try to find the what the issue is.
I thought it was the code but now I'm not so sure. Thank you all for your time. If there is anything you need let me know and I'll get it to you as fast as I can.

#include "TM4C123.h"                    // Device header
#include <stdlib.h>
//General Input/ouput Run Mode Clock Gating Control RCGCGPIO pg 340
//This enables our F port
#define SYSCTL_RCGCGPIO_R (*((volatile unsigned long *) 0x400FE608))
	
 
//GPIO direction binary (000000000001110),we choose this because according to
//pg 663, we must choose which pins in port F we want to be either an input or output. 
#define GPIO_PORTF_DIR_R (*((volatile unsigned long *) 0x40025400))
 
//Digial enable or DEN pg 683  page number 682-683 
//The digital functions for the corresponding pin are enabled
//once you find the binary value for this setting convert to hexadecimal
#define GPIO_PORTF_DEN_R (*((volatile unsigned long *)0x4002551C ))// base address + offset = 04x4002551C 
 
//GPIODATA see page 662 of the datasheet. base + offset is 0x40025000 + the pins we want to enable (bianry value: 0000011100) represent as hexadecimal as 0x038
//= 0x40025038
#define GPIO_PORTF_DATA_R (* (( volatile unsigned long *) 0x40025038)) 
 
//assign values to registers . The pin 1 enable button to have value 0x020 
#define GPIO_PORTF_CLK_EN 0x20 //enable clock port F
 
#define GPIO_PORTF_PIN1_EN 0x02 //pin position
#define LED_ON1 0x02 // binary of the red pin or PF1: 000000000000010
 
#define GPIO_PORTF_PIN2_EN 0x04//PIN POSITION
#define LED_ON2 0x04 // binary representation of Blue pin or PF2: 000000000000100
 
#define GPIO_PORTF_PIN3_EN 0x08 //pin position
#define LED_ON3 0x08 // Binary representation of the green pin or PF3: 000000000001000
 
void Delay(void);
 
static int j = 0;
void Delay(void)
{
	
	for (j=0; j<1000 ; j++);
}
 
int main (void)
{
	//The “|=” operator is an OR operator and it will simply add the value at the right to the variable given at the left. 
	volatile unsigned long ulLoop ;
	SYSCTL_RCGCGPIO_R |= GPIO_PORTF_CLK_EN ;
	ulLoop = SYSCTL_RCGCGPIO_R;		
	
	GPIO_PORTF_DIR_R |= GPIO_PORTF_PIN1_EN ;
	GPIO_PORTF_DEN_R |= GPIO_PORTF_PIN1_EN ;	
	GPIO_PORTF_DIR_R |= GPIO_PORTF_PIN2_EN ;
	GPIO_PORTF_DEN_R |= GPIO_PORTF_PIN2_EN ;
	GPIO_PORTF_DIR_R |= GPIO_PORTF_PIN3_EN ;
	GPIO_PORTF_DEN_R |= GPIO_PORTF_PIN3_EN ;
	while (1)
	{
		GPIO_PORTF_DATA_R &= LED_ON3; 
		GPIO_PORTF_DATA_R &= LED_ON2;
		GPIO_PORTF_DATA_R |= LED_ON1;
		Delay();
		GPIO_PORTF_DATA_R &= LED_ON3; 
		GPIO_PORTF_DATA_R &= LED_ON2;
		GPIO_PORTF_DATA_R |= LED_ON1;
		Delay();
		GPIO_PORTF_DATA_R &= LED_ON3; 
		GPIO_PORTF_DATA_R &= LED_ON2;
		GPIO_PORTF_DATA_R |= LED_ON1;
		Delay();
	}
	
	return 0;
}
  • Hello Brandon,

    The LED is not static. We have a demo project in TivaWare to blink the LED called 'blinky' which can be found under examples\boards\ek-tm4c123gxl.

    We don't support DRM code as you posted above on E2E so please start from our TivaWare DriverLib examples. If you need DRM for some reason then you can look at the source code of our DriverLib APIs to see the DRM calls.

    By the way from your code, you are executing the same sequence of calls after each delay so nothing is changing with the register configs at all. I think maybe you mean to do a different order of LED_ON1/2/3 each time but that isn't reflected.

  • This did help, thank you for telling me about these sample programs, I knew TI had some, I just didn't know it was in the form of an .exe download. So I noticed that for the delay, when I use int datatype it crashes the program. When I used the uint32_t datatype, it works just fine. Any clue why this is the case? Maybe this is why my other codes were not working? They all used the int datatype to make a delay. 

  • Hi Brandon,

    It would depend how your delay is coded. The issue with int vs uint32_t is whether or not the value is signed. For TivaWare APIs you need to be using the name type as the function declaration or your will have a mismatch of data types and that can cause errors in the system. But if you made your own delay function without TivaWare APIs then it may be okay depending how you are using the int values vs the device register settings (which are unsigned).