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.

求助TM4C1294的LED灯点亮问题



这是所写代码

void main(void)

{

SysCtlPeripheralEnable(SYSCTL_PERIPH_GPIOF);
GPIODirModeSet(GPIO_PORTF_BASE,GPIO_PIN_1,GPIO_DIR_MODE_OUT);
GPIOPadConfigSet(GPIO_PORTF_BASE,GPIO_PIN_1,GPIO_STRENGTH_8MA_SC,GPIO_PIN_TYPE_STD);
GPIOPinWrite(GPIO_PORTF_BASE,GPIO_PIN_1,0xff);
while(1)
{};
}

编译后显示

CORTEX_M4_0: GEL Output:
Memory Map Initialization Complete

但板子上LED灯D1,D2,D3不亮

  • GPIOPinWrite的第三个参数写入不正确。你的系统时钟的设置在哪呢?
  • 第三个参数修改后,加入系统时钟,LED灯仍不亮

  • #include <stdint.h>
    #include <stdbool.h>
    #include "inc/hw_ints.h"
    #include "inc/hw_memmap.h"
    #include "inc/hw_nvic.h"
    #include "inc/hw_types.h"
    #include "driverlib/gpio.h"
    #include "driverlib/interrupt.h"
    #include "driverlib/pin_map.h"
    #include "driverlib/systick.h"
    #include "driverlib/sysctl.h"
    #include "driverlib/timer.h"
    #include "utils/uartstdio.h"

    void main(void)
    {

    SysCtlPeripheralEnable (SYSCTL_PERIPH_GPIOF);
    GPIODirModeSet(GPIO_PORTF_BASE,GPIO_PIN_1,GPIO_DIR_MODE_OUT);
    GPIOPadConfigSet(GPIO_PORTF_BASE,GPIO_PIN_1,GPIO_STRENGTH_8MA_SC,GPIO_PIN_TYPE_STD);
    GPIOPinWrite(GPIO_PORTF_BASE,GPIO_PIN_1,GPIO_PIN_1);
    while(1)
    {};
    }
  • 没看到你主时钟的设置在哪,给你一个LED闪烁的例程

    //*****************************************************************************
    //
    // project0.c - Example to demonstrate minimal TivaWare setup
    //
    // Copyright (c) 2012-2017 Texas Instruments Incorporated.  All rights reserved.
    // Software License Agreement
    // 
    // Texas Instruments (TI) is supplying this software for use solely and
    // exclusively on TI's microcontroller products. The software is owned by
    // TI and/or its suppliers, and is protected under applicable copyright
    // laws. You may not combine this software with "viral" open-source
    // software in order to form a larger program.
    // 
    // THIS SOFTWARE IS PROVIDED "AS IS" AND WITH ALL FAULTS.
    // NO WARRANTIES, WHETHER EXPRESS, IMPLIED OR STATUTORY, INCLUDING, BUT
    // NOT LIMITED TO, IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
    // A PARTICULAR PURPOSE APPLY TO THIS SOFTWARE. TI SHALL NOT, UNDER ANY
    // CIRCUMSTANCES, BE LIABLE FOR SPECIAL, INCIDENTAL, OR CONSEQUENTIAL
    // DAMAGES, FOR ANY REASON WHATSOEVER.
    // 
    // This is part of revision 2.1.4.178 of the EK-TM4C1294XL Firmware Package.
    //
    //*****************************************************************************
    
    #include <stdint.h>
    #include <stdbool.h>
    #include "inc/hw_types.h"
    #include "inc/hw_memmap.h"
    #include "driverlib/sysctl.h"
    #include "driverlib/gpio.h"
    
    //*****************************************************************************
    //
    // Define pin to LED mapping.
    //
    //*****************************************************************************
    
    //*****************************************************************************
    //
    //! \addtogroup example_list
    //! <h1>Project Zero (project0)</h1>
    //!
    //! This example demonstrates the use of TivaWare to setup the clocks and
    //! toggle GPIO pins to make the LED blink. This is a good place to start
    //! understanding your launchpad and the tools that can be used to program it.
    //
    //*****************************************************************************
    
    #define USER_LED1  GPIO_PIN_0
    #define USER_LED2  GPIO_PIN_1
    
    //*****************************************************************************
    //
    // The error routine that is called if the driver library encounters an error.
    //
    //*****************************************************************************
    #ifdef DEBUG
    void
    __error__(char *pcFilename, uint32_t ui32Line)
    {
    }
    #endif
    
    //*****************************************************************************
    //
    // Main 'C' Language entry point.  Toggle an LED using TivaWare.
    //
    //*****************************************************************************
    int
    main(void)
    {
        uint32_t ui32SysClock;
    
        //
        // Run from the PLL at 120 MHz.
        //
        ui32SysClock = SysCtlClockFreqSet((SYSCTL_XTAL_25MHZ |
                                           SYSCTL_OSC_MAIN |
                                           SYSCTL_USE_PLL |
                                           SYSCTL_CFG_VCO_480), 120000000);
    
        //
        // Enable and wait for the port to be ready for access
        //
        SysCtlPeripheralEnable(SYSCTL_PERIPH_GPION);
        while(!SysCtlPeripheralReady(SYSCTL_PERIPH_GPION))
        {
        }
        
        //
        // Configure the GPIO port for the LED operation.
        //
        GPIOPinTypeGPIOOutput(GPIO_PORTN_BASE, (USER_LED1|USER_LED2));
    
        //
        // Loop Forever
        //
        while(1)
        {
            //
            // Turn on the LED
            //
            GPIOPinWrite(GPIO_PORTN_BASE, (USER_LED1|USER_LED2), USER_LED1);
    
            //
            // Delay for a bit
            //
            SysCtlDelay(ui32SysClock/6);
    
            //
            // Turn on the LED
            //
            GPIOPinWrite(GPIO_PORTN_BASE, (USER_LED1|USER_LED2), USER_LED2);
    
            //
            // Delay for a bit
            //
            SysCtlDelay(ui32SysClock/6);
        }
    }