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.

[参考译文] TM4C1294KCPDT:TM4C1294KCPDT

Guru**** 2468460 points
Other Parts Discussed in Thread: EK-TM4C1294XL

请注意,本文内容源自机器翻译,可能存在语法或其它翻译错误,仅供参考。如需获取准确内容,请参阅链接中的英语原文或自行翻译。

https://e2e.ti.com/support/microcontrollers/arm-based-microcontrollers-group/arm-based-microcontrollers/f/arm-based-microcontrollers-forum/1465637/tm4c1294kcpdt-tm4c1294kcpdt

器件型号:TM4C1294KCPDT
Thread 中讨论的其他器件:EK-TM4C1294XL

工具与软件:

我正在使用开发板 EK-TM4C1294XL

板上的两个触控开关(USR_SW1)和 USR_SW)不执行任何操作。

我们针对轮询和中断操作模式编译了程序、但两个开关仍然没有执行任何操作。

我们通过调试端口监控 CPU 操作。

如果另一个引脚被切换、那么上面的两个开关看起来起作用。

请提供建议。

这一点极其重要

  • 请注意,本文内容源自机器翻译,可能存在语法或其它翻译错误,仅供参考。如需获取准确内容,请参阅链接中的英语原文或自行翻译。
    [报价 userid="546573" url="~/support/microcontrollers/arm-based-microcontrollers-group/arm-based-microcontrollers/f/arm-based-microcontrollers-forum/1465637/tm4c1294kcpdt-tm4c1294kcpdt "]

    如果另一个引脚被切换、那么上面的两个开关看起来起作用。

    [报价]

    您好!

     您意味着另一个开关被切换然后这两个开关将工作? 您谈到的是哪个引脚? 请参考以下代码、其中 USER_SW1 (PJ0)配置为生成中断。 每次按下开关时、它都会改变电路板上的 LED 闪烁速率。  如果已正确配置引脚以进行边沿检测、请与您的代码进行比较。  

    #include <stdbool.h>
    #include <stdint.h>
    #include "inc/hw_ints.h"
    #include "inc/hw_memmap.h"
    #include "driverlib/gpio.h"
    #include "driverlib/interrupt.h"
    #include "driverlib/pin_map.h"
    #include "driverlib/sysctl.h"
    #include "driverlib/timer.h"
    #include "driverlib/uart.h"
    #include "utils/uartstdio.h"
    
    
    #define USER_LED1  GPIO_PIN_0
    #define USER_LED2  GPIO_PIN_1
    uint32_t ui32SysClock;
    
    
    //*****************************************************************************
    //
    // Counter to count the number of interrupts that have been called.
    //
    //*****************************************************************************
    static volatile uint32_t g_ui32Counter = 0;
    
    
    //*****************************************************************************
    //
    // The interrupt handler for the Timer0 interrupt.
    //
    //*****************************************************************************
    void
    Timer0IntHandler(void)
    {
        //
        // Clear the timer interrupt flag.
        //
        TimerIntClear(TIMER0_BASE, TIMER_TIMA_TIMEOUT);
    
    
        if ((g_ui32Counter % 2) == 0){
            GPIOPinWrite(GPIO_PORTN_BASE, (USER_LED1|USER_LED2), USER_LED1);
    
        } else {
            GPIOPinWrite(GPIO_PORTN_BASE, (USER_LED1|USER_LED2), USER_LED2);
    
        }
    
        //
        // Update the periodic interrupt counter.
        //
        g_ui32Counter++;
    
    
    }
    
    void SW1Handler (void)
    {
        GPIOIntClear(GPIO_PORTJ_BASE, GPIO_PIN_0);
        ui32SysClock *= 1.2;
        TimerLoadSet(TIMER0_BASE, TIMER_A, ui32SysClock / 2);
    
    }
    
    
    
    //*****************************************************************************
    //
    // Configure Timer0B as a 16-bit periodic counter with an interrupt
    // every 1ms.
    //
    //*****************************************************************************
    int
    main(void)
    {
    
    
    
        //
        // Set the clocking to run directly from the external crystal/oscillator.
        // TODO: The SYSCTL_XTAL_ value must be changed to match the value of the
        // crystal on your board.
        //
    
        ui32SysClock = SysCtlClockFreqSet((SYSCTL_XTAL_25MHZ |
                                           SYSCTL_OSC_MAIN |
                                           SYSCTL_USE_OSC), 25000000);
    
        //
        // The Timer0 peripheral must be enabled for use.
        //
        SysCtlPeripheralEnable(SYSCTL_PERIPH_TIMER0);
    
        //
        // 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));
    
        SysCtlPeripheralEnable(SYSCTL_PERIPH_GPIOJ);
        while(!(SysCtlPeripheralReady(SYSCTL_PERIPH_GPIOJ)));
        GPIOPinTypeGPIOInput(GPIO_PORTJ_BASE, GPIO_PIN_0);
        GPIOPadConfigSet(GPIO_PORTJ_BASE, GPIO_PIN_0, GPIO_STRENGTH_2MA, GPIO_PIN_TYPE_STD_WPU);
        GPIOIntTypeSet(GPIO_PORTJ_BASE, GPIO_PIN_0, GPIO_FALLING_EDGE);
        GPIOIntRegister(GPIO_PORTJ_BASE, SW1Handler);
        GPIOIntEnable(GPIO_PORTJ_BASE, GPIO_INT_PIN_0);
        IntEnable(INT_GPIOJ);
        //
        // Configure Timer0B as a 16-bit periodic timer.
        //
        TimerConfigure(TIMER0_BASE,  TIMER_CFG_PERIODIC);
    
    
        //
        // Set the Timer0B load value to 1ms.
        //
        TimerLoadSet(TIMER0_BASE, TIMER_A, ui32SysClock / 2);
    
        //
        // Enable processor interrupts.
        //
        IntMasterEnable();
    
        //
        // Configure the Timer0B interrupt for timer timeout.
        //
        TimerIntEnable(TIMER0_BASE, TIMER_TIMA_TIMEOUT);
    
        //
        // Enable the Timer0B interrupt on the processor (NVIC).
        //
        IntEnable(INT_TIMER0A);
    
        //
        // Initialize the interrupt counter.
        //
        g_ui32Counter = 0;
    
        //
        // Enable Timer0B.
        //
        TimerEnable(TIMER0_BASE, TIMER_A);
    
        //
        // Loop forever while the Timer0B runs.
        //
        while(1)
        {
    
        }
    }