Beginner Help on Non Maskable Interrupt Cortex M3

Hi All,

I am trying to get basic uart functionality going on a LM3S2772 and I am having trouble with the program entering the NMI handler.

this occurs when I try and configure the GPIO to Uart function. (GPIOPinTypeUART) - From Stellaris library

Function is called with arguments

GPIO_PORTA_BASE = 0x40004000

GPIO_PIN_0 = 0x00000001

GPIO_PIN_1 = 0x00000002

Any help will be greatly appreciated !

CODE:

int
main(void)
{
    volatile unsigned long ulLoop;

    //
    // Enable the GPIO port that is used for the on-board LED.
    //
    SYSCTL_RCGC2_R = SYSCTL_RCGC2_GPIOB;
    //SYSCTL_RCGC2_R = SYSCTL_RCGC2_GPIOG;

    //Enable Uart0
    SysCtlPeripheralEnable(SYSCTL_PERIPH_UART0);

    // Set GPIO A0 and A1 as UART pins.////
       //
    GPIOPinTypeUART(GPIO_PORTA_BASE, GPIO_PIN_0 | GPIO_PIN_1); //<--------- HERE. PC enters NMIsr at this point, does not execute first line in this function !!
       //
       // Configure the UART for 115,200, 8-N-1 operation.
       //
    UARTConfigSetExpClk(UART0_BASE, SysCtlClockGet(), 115200,
                           (UART_CONFIG_WLEN_8 | UART_CONFIG_STOP_ONE |
                            UART_CONFIG_PAR_NONE));


    //
    // Do a dummy read to insert a few cycles after enabling the peripheral.
    //
    ulLoop = SYSCTL_RCGC2_R;

    //
    // Enable the GPIO pin for the LED (PG1).  Set the direction as output, and
    // enable the GPIO pin for digital function.
    //PB1 AND PB4

    GPIO_PORTB_DIR_R = 0x12;
    GPIO_PORTB_DEN_R = 0x12;

Still having trouble with this.

I have narrowed down the exact line of code where the Fault Interrupt is occurring.

-You can see where I am toggling some LEDs for debugging…

I really hope someone can shed some light on to this!

GPIOPinTypeUART(…) Calls GPIODirModeSet(…)

In gpio.c

void
GPIODirModeSet(unsigned long ulPort, unsigned char ucPins,
               unsigned long ulPinIO)
{
	GPIO_PORTB_DATA_R |= 0x02;
    //
    // Check the arguments.
    //
    //ASSERT(GPIOBaseValid(ulPort));
   // ASSERT((ulPinIO == GPIO_DIR_MODE_IN) || (ulPinIO == GPIO_DIR_MODE_OUT) ||
    //       (ulPinIO == GPIO_DIR_MODE_HW));

    GPIO_PORTB_DATA_R |= 0x10;


    //
    // Set the pin direction and mode.
    //
    HWREG(ulPort + GPIO_O_DIR) = ((ulPinIO & 1) ?
                                  (HWREG(ulPort + GPIO_O_DIR) | ucPins) :
                                  (HWREG(ulPort + GPIO_O_DIR) & ~(ucPins))); // <---------- When I step past this line, program goes to FaultISR()

    GPIO_PORTB_DATA_R |= 0x20;

    HWREG(ulPort + GPIO_O_AFSEL) = ((ulPinIO & 2) ?
                                    (HWREG(ulPort + GPIO_O_AFSEL) | ucPins) :
                                    (HWREG(ulPort + GPIO_O_AFSEL) & ~(ucPins)));
}

Fixed

Duh, wasn’t enabling port A before writing

All of my mistakes are, in hindsight, dumb.