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);
}
}