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.

LM4F120 LaunchPad bricked

Other Parts Discussed in Thread: ENERGIA, LMFLASHPROGRAMMER

Thanks for taking the time to read this.

I have little experience with this chip. I just got three LM4F120 LaunchPad boards in the mail the other day and I have been programming it with Energia. I have the basics down, blinking LEDs, driving a Nokia 5110. In an attempt to read a GPS module, from TX 3 and RX3 I found and ran the following code. The good news is that I was able to read the GPS data on the serial monitor, the bad news is that the LaunchPad can not be reprogrammed. I opened a new LM4F120 LaunchPad and loaded several example programs with no problems. Then I loaded the GPS code into the second LaunchPad and it worked, I was able to read the GPS data on the serial monitor, but when I tried to reprogram the board the program compiles fine but hangs  before programing the board. The computer sees the board and the com port,  that the board is on. I have changed the usb cables, usb ports, reloaded the drivers, tried to use the LM Flash Programer but LM Flash can not find the device. Could the code that I loaded cause the problem and is there anyway to recover the boards? I don't what to brick the third LaunchPad.



tx Bob

/// Start

#define UART_NUM = 7

#define UART_BASE UART3_BASE

#define INT_UART INT_UART3

#define PERIPHERAL_UART SYSCTL_PERIPH_UART3

#define PERIPHERAL_GPIO SYSCTL_PERIPH_GPIOC

#define GPIO_BASE GPIO_PORTC_BASE

#define GPIO_PINS (GPIO_PIN_6 | GPIO_PIN_7)

#define PCTL_PINS (GPIO_PCTL_PC6_U3RX | GPIO_PCTL_PC7_U3TX )



#include "inc/hw_ints.h"

#include "inc/hw_memmap.h"

#include "inc/hw_types.h"

#include "inc/hw_gpio.h"

#include "driverlib/debug.h"

#include "driverlib/gpio.h"

#include "driverlib/sysctl.h"

#include "driverlib/interrupt.h"

#include "driverlib/rom.h"

#include "driverlib/sysctl.h"

#include "driverlib/uart.h"



#undef GPIO_LOCK_KEY

#include "inc/lm4f120h5qr.h"



void setup(){

}



#ifdef DEBUG

void

__error__(char *pcFilename, unsigned long ulLine)

{

}

#endif



unsigned long ulStatus;

unsigned char c;



void

UARTIntHandler(void)

{

//unsigned long ulStatus;

//unsigned char c;

//

// Get the interrrupt status.

//

ulStatus = ROM_UARTIntStatus(UART_BASE, true);



//

// Clear the asserted interrupts.

//

ROM_UARTIntClear(UART_BASE, ulStatus);



//

// Loop while there are characters in the receive FIFO.

//

while(ROM_UARTCharsAvail(UART_BASE))

{



//

// Read the next character from the UART and write it back to the UART.

//

//ROM_UARTCharPutNonBlocking(UART_BASE,ROM_UARTCharGetNonBlocking(UART_BASE));

c = (unsigned char)ROM_UARTCharGetNonBlocking(UART_BASE);

//c = c >> 4;

UARTCharPut(UART0_BASE, c);

ROM_UARTCharPutNonBlocking(UART_BASE, c);

}

}



//Not used but not removed

void

UARTSend(const unsigned char *pucBuffer, unsigned long ulCount)

{

//

// Loop while there are more characters to send.

//

while(ulCount--)

{

//

// Write the next character to the UART.

//

ROM_UARTCharPutNonBlocking(UART_BASE, *pucBuffer++);

}

}



//int

//main(void)



void loop()

{

//

// Set the clocking to run directly from the crystal, this setup gives a 16MHz clock

//

ROM_SysCtlClockSet(SYSCTL_SYSDIV_1 | SYSCTL_USE_OSC | SYSCTL_OSC_MAIN |

SYSCTL_XTAL_16MHZ);



//Start Initialize UART0

SysCtlPeripheralEnable(SYSCTL_PERIPH_UART0);

SysCtlPeripheralEnable(SYSCTL_PERIPH_GPIOA);

GPIOPinConfigure(GPIO_PC6_U3RX);

GPIOPinConfigure(GPIO_PA1_U0TX);

GPIOPinTypeUART(GPIO_PORTA_BASE, GPIO_PIN_0 | GPIO_PIN_1);

UARTConfigSetExpClk(UART0_BASE, SysCtlClockGet(), 9600,

(UART_CONFIG_WLEN_8 | UART_CONFIG_STOP_ONE |

UART_CONFIG_PAR_NONE));

UARTCharPut(UART0_BASE, '!');

//End Initializing UART0

//

// Enable the peripherals used by this example.

//

ROM_SysCtlPeripheralEnable(PERIPHERAL_UART);

ROM_SysCtlPeripheralEnable(PERIPHERAL_GPIO);

//

// Set up I/O pins for chosen port

//

ROM_GPIOPinTypeUART(GPIO_BASE, GPIO_PINS);

//

// Enable processor interrupts.

//

ROM_IntMasterEnable();

//



// more configuration for uarts1/2 - this is in fact the only extra code needed for UART1/2

//#ifdef UART_NUM != 0

HWREG(GPIO_BASE + GPIO_O_PCTL) = PCTL_PINS ;

//#endif

//

// Configure the UART for 9600, 8-N-1 operation.

//

ROM_UARTConfigSetExpClk(UART_BASE, ROM_SysCtlClockGet(), 9600, /*115200,*/

(UART_CONFIG_WLEN_8 | UART_CONFIG_STOP_ONE |

UART_CONFIG_PAR_NONE));



UARTFIFOLevelSet(UART_BASE, UART_FIFO_TX1_8, UART_FIFO_RX1_8);



//

// Enable the UART interrupt.

//



// this line below was added to replace the code in startup.c



UARTIntRegister(UART_BASE,UARTIntHandler);

ROM_IntEnable(INT_UART);

ROM_UARTIntEnable(UART_BASE, UART_INT_RX | UART_INT_RT);

//

// Prompt for text to be entered.

//

while (1) {

UARTSend((unsigned char *)"\033[2JEnter text: ", 16);

SysCtlDelay(1000);

}

// Loop forever echoing data through the UART.

//



c = 'N';

while(true)

{

c = (unsigned char)ROM_UARTCharGetNonBlocking(UART_BASE);

ROM_UARTCharPutNonBlocking(UART_BASE, c);

SysCtlDelay(1000);

}



}

  • Download The Latest  LMFlash and attempt the unlock routine.

    Let us know if that cures it. I think PORT C is the port with the debugger -- so yeah -- you need to unlock it now.

    http://www.ti.com/tool/lmflashprogrammer

    Sorry -- meant to say latest since you did not give version. You may have to hold reset while attempting repair. Other tricks are on this forum as well.

  • Thanks Dave, that worked, do you know what line in the code causes the lock up?

  • You are re-purposing port C on the ARM to use UART for the GPS.  This port contains the pins for jtag.  So when you set them to UART in your program and write that the ARM now the pins are no longer for JTAG.  The unlock procedure you did earlier sets these back to default.  You need to either use a UART on a different port (should be plenty to choose from) or use some sort of delay routine where set the pins for jtag then wait so long and then turn them to uart.  That way if you reset the board you have how ever long you gave yourself to hit program.  Another common example (one I use with most bootloaders) is to check the status of a button or switch and if the switch is pressed when the MCU boots then go into jtag mode and wait to be programmed and reset.

    -Zack- 

    *edit - sorry guys have been scouring the forums and didn't realize how old this post was.  I apologize for resurrecting it.

  • Zachery Littell said:
    sorry guys have been scouring the forums and didn't realize how old this post was.  I apologize for resurrecting it

    Well, the whole thread is less than a month old, so it's still relatively fresh.  At least you weren't responding to a post from 4 years ago and talking about solutions that only apply to parts that didn't even exist when the original question was posed.

  • Thanks Zack, I had moved to PORTE, and that has been working.