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.

F28M35x 外部中断异常的问题



请教:关于设置好GPIO20作为M3的外部中断,下降沿触发,当中断条件发生时,程序会进入startup_ccs.c的死循环IntDefaultHandler()函数中;而且根据观察当外部引脚电平发生变化时,即中断条件满足时,程序并未进入中断而是直接跳转到了死循环IntDefaultHandler()函数中。请朋友们帮忙分析一下,谢谢!还有个问题不知道CCS环境中有没有办法可以查询到IntDefaultHandler()函数是被谁调用的,附上程序:

#include "inc/hw_ints.h"
#include "inc/hw_memmap.h"
#include "inc/hw_nvic.h"
#include "inc/hw_gpio.h"
#include "inc/hw_types.h"
#include "inc/hw_sysctl.h"
#include "driverlib/debug.h"
#include "driverlib/interrupt.h"
#include "driverlib/sysctl.h"
#include "driverlib/gpio.h"

void GPIOJIntHandler(void)
{
 GPIOPinWrite(GPIO_PORTC_BASE, GPIO_PIN_7, 0);
  volatile unsigned long ulIntStatus,toggle1=0;//ulLoop,
  // 获取PD口的中断状态
    ulIntStatus = GPIOPinIntStatus(GPIO_PORTJ_BASE,true);
     // 清除PD口的中断
    GPIOPinIntClear(GPIO_PORTJ_BASE,ulIntStatus);
// GPIOPinIntClear(GPIO_PORTJ_BASE,1);
    if(toggle1==0)
    {
     GPIOPinWrite(GPIO_PORTC_BASE, GPIO_PIN_7, 0);
     toggle1=1;
    }
    else
    {
     GPIOPinWrite(GPIO_PORTC_BASE, GPIO_PIN_7, ~0);
     toggle1=0;
    }

}

//*****************************************************************************
// The error routine that is called if the driver library encounters an error.
//*****************************************************************************
#ifdef DEBUG
void
__error__(char *pcFilename, unsigned long ulLine)
{
}

#endif

//*****************************************************************************
//
// Blink LED3
//*****************************************************************************
int
main(void)
{

    volatile unsigned long ulLoop;

    // Disable Protection
    HWREG(SYSCTL_MWRALLOW) =  0xA5A5A5A5;

    // Sets up PLL, M3 running at 100MHz and C28 running at 100MHz
    SysCtlClockConfigSet(SYSCTL_USE_PLL | (SYSCTL_SPLLIMULT_M & 0xA) |
                         SYSCTL_SYSDIV_1 | SYSCTL_M3SSDIV_1 |
                         SYSCTL_XCLKDIV_4);

    // Enable clock supply for GPIOC
    SysCtlPeripheralEnable(SYSCTL_PERIPH_GPIOC);
    //使用GPIOD——GPIO20作为中断输入
    SysCtlPeripheralEnable(SYSCTL_PERIPH_GPIOJ);
    //设置PD口的状态,GPIO20作为输入中断引脚,配置GPIO20为弱上拉
    GPIOPinTypeGPIOInput(GPIO_PORTJ_BASE, GPIO_PIN_4);
    GPIOPadConfigSet(GPIO_PORTJ_BASE,GPIO_PIN_4,GPIO_PIN_TYPE_STD_WPU);
    GPIOPortIntRegister(INT_GPIOJ,GPIOJIntHandler);
    //设置PD口的中断,下降沿触发
    GPIOIntTypeSet(GPIO_PORTJ_BASE, GPIO_PIN_4, GPIO_FALLING_EDGE);//GPIO_FALLING_EDGE);GPIO_BOTH_EDGES
    //使能NVIC中断,设置中断优先级
    IntPrioritySet(INT_GPIOJ,0x00);
    //使能PJ口中断
    IntEnable(INT_GPIOJ);
    //使能PJ口,GPIO20的中断
    GPIOPinIntEnable(GPIO_PORTJ_BASE, GPIO_PIN_4);
    // Disable clock supply for the watchdog modules
    SysCtlPeripheralDisable(SYSCTL_PERIPH_WDOG1);
    SysCtlPeripheralDisable(SYSCTL_PERIPH_WDOG0);
    // Enable processor interrupts.
    IntMasterEnable();
    // Set up the Pin for LED3
    GPIOPinTypeGPIOOutput(GPIO_PORTC_BASE, GPIO_PIN_7);
    GPIOPinTypeGPIOOutput(GPIO_PORTC_BASE, GPIO_PIN_6);
    GPIOPinWrite(GPIO_PORTC_BASE, GPIO_PIN_7, ~0);
    GPIOPinWrite(GPIO_PORTC_BASE, GPIO_PIN_6, ~0);
   
    // Loop forever while the timers run.
    while(1)
    {
        //
        // Turn on the LED.
        //
        GPIOPinWrite(GPIO_PORTC_BASE, GPIO_PIN_6, 0);
        //
        // Delay for a bit.
        //
        for(ulLoop = 0; ulLoop < 2000000; ulLoop++)
        {
        }
        //
        // Turn off the LED.
        //
        GPIOPinWrite(GPIO_PORTC_BASE, GPIO_PIN_6, ~0);
        //
        // Delay for a bit.
        //
        for(ulLoop = 0; ulLoop < 2000000; ulLoop++)
        {
        }

    }
}