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.

Compiler/EK-TM4C1294XL: Program not working

Part Number: EK-TM4C1294XL

Tool/software: TI C/C++ Compiler

Hi,

I am trying to blink 2 led's but it is not happening. Please review and correct the code. I am using Tiva C series EK-TM4C1294XL board.

#include <stdint.h>
#include <stdbool.h>
#include "inc/hw_memmap.h"
#include "driverlib/debug.h"
#include "driverlib/gpio.h"
#include "driverlib/sysctl.h"

//*****************************************************************************
//
//! \addtogroup example_list
//! <h1>Blinky (blinky)</h1>
//!
//! A very simple example that blinks the on-board LED using direct register
//! access.
//
//*****************************************************************************

//*****************************************************************************
//
// The error routine that is called if the driver library encounters an error.
//
//*****************************************************************************

#ifdef DEBUG
void
__error__(char *pcFilename, uint32_t ui32Line)
{
    while(1);
}
#endif

//*****************************************************************************
//
// Blink the on-board LED.
//
//*****************************************************************************
int
main(void)
{
    volatile uint32_t ui32Loop;

    //
    // Enable the GPIO port that is used for the on-board LED.
    //
    SysCtlPeripheralEnable(SYSCTL_PERIPH_GPION);

    //
    // Check if the peripheral access is enabled.
    //
    while(!SysCtlPeripheralReady(SYSCTL_PERIPH_GPION))
    {
    }

    //
    // Enable the GPIO pin for the LED (PN0).  Set the direction as output, and
    // enable the GPIO pin for digital function.
    //
    GPIOPinTypeGPIOOutput(GPIO_PORTF_BASE, GPIO_PIN_0 | GPIO_PIN_4);

    //
    // Loop forever.
    //
    while(1)
    {
        //
        // Turn on the LED.
        //
        GPIOPinWrite(GPIO_PORTF_BASE, GPIO_PIN_4 | GPIO_PIN_0, GPIO_PIN_4 | GPIO_PIN_4);

        //
        // Delay for a bit.
        //
        for(ui32Loop = 0; ui32Loop < 200000; ui32Loop++)
        {
        }

        //
        // Turn off the LED.
        //
        GPIOPinWrite(GPIO_PORTF_BASE, GPIO_PIN_4 | GPIO_PIN_0, 0);

        //
        // Delay for a bit.
        //
        for(ui32Loop = 0; ui32Loop < 200000; ui32Loop++)
        {
        }
    }
    }

Thanks and Regards,

Anubhav

  • Hi, welcome to the forum.

    First let me suggest that to make it easier to help you, you give more specific information when you request help. For example, saying "please review and correct my code" does not help us help you. Instead saying my code jumps to the fault interrupt service routine when I C step the GPIPinTypeOutput function in line 58 would be very descriptive of your problem. It shows what you have tried and pinpoints the focus for those who would help you.

    Also, I suggest you use the </> button when posting code. It preserves the formatting.

    The reason you code jumps to the FaultISR routine is that in line 58 you access GPIO port F, but you have not enabled the clocks for that port yet. In lines 50 and 58 you enable the clocks for GPIO port N. I suspect you meant to change those to port F.

    Also, in line 68, the third parameter of the function GPIOPinWrite you have "GPIO_PIN_4 | GPIO_PIN_4". If you want both LEDs to turn on it should be "GPIO_PIN_4 | GPIO_PIN_0".