TI中文支持网
TI专业的中文技术问题搜集分享网站

6748外部中断问题

神一样的技术人员你好:

        我写了一个外部中断程序,不知道为什么进不了中断函数,请大师看看。

/**
 * \file    gpioCardDetect.c
 *
 * \brief   This is a sample application file demonstrating the use of
 *          a GPIO pin to generate an interrupt whenever an MMC/SD card
 *          is inserted or ejected from the Evaluation Module(EVM).
 */

/*
* Copyright (C) 2012 Texas Instruments Incorporated – http://www.ti.com/
*
*  Redistribution and use in source and binary forms, with or without
*  modification, are permitted provided that the following conditions
*  are met:
*
*    Redistributions of source code must retain the above copyright
*    notice, this list of conditions and the following disclaimer.
*
*    Redistributions in binary form must reproduce the above copyright
*    notice, this list of conditions and the following disclaimer in the
*    documentation and/or other materials provided with the
*    distribution.
*
*    Neither the name of Texas Instruments Incorporated nor the names of
*    its contributors may be used to endorse or promote products derived
*    from this software without specific prior written permission.
*
*  THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
*  "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
*  LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
*  A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
*  OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
*  SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
*  LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
*  DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
*  THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
*  (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
*  OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/

#include "gpio.h"
#include "interrupt.h"
#include "psc.h"
//#include "Sys_Init.h"
#include "soc_C6748.h"
#include "lcdkC6748.h"

volatile unsigned char flag = 0;

/****************************************************************************/
/*              LOCAL FUNCTION PROTOTYPES                                   */
/****************************************************************************/
static void Delay(volatile unsigned int delay);
void EVMC6748_pinmuxConfig(unsigned int in_reg, unsigned int in_mask, unsigned int in_val) ;
static void InitDspIntc(void) ;
static void GPIOIsr(void) ;
/****************************************************************************/
/*              GLOBAL VARIABLES                                            */
/****************************************************************************/

/****************************************************************************/
/*             LOCAL FUNCTION DEFINITIONS                                   */
/****************************************************************************/

int main(void)
{

 int i = 0 ;
 PSCModuleControl(SOC_PSC_1_REGS, HW_PSC_GPIO, PSC_POWERDOMAIN_ALWAYS_ON,
        PSC_MDCTL_NEXT_ENABLE);

 

 EVMC6748_pinmuxConfig(6,0xF000,0x8000);
 GPIODirModeSet(SOC_GPIO_0_REGS, 37, GPIO_DIR_INPUT);
 GPIODirModeSet(SOC_GPIO_0_REGS, 37, GPIO_INT_TYPE_RISEDGE);

 GPIOBankIntEnable(SOC_GPIO_0_REGS, 2);

 InitDspIntc() ;
 while(1)
 {
  i ++ ;
  Delay(1000000);
 }
}
/*

 ** \brief  This function sets up the status of interrupt.

 **

*/

static void InitDspIntc(void)

 {

     IntDSPINTCInit();         //initialize the interrupt controller

     IntGlobalEnable();         //enable DSP CPU interrupts globally

     IntRegister(C674X_MASK_INT4, GPIOIsr);    //register the ISR in the interrupt vector table

     IntEventMap(C674X_MASK_INT4, SYS_INT_GPIO_B2INT); //map the system event GPIO_Bank2(BUTTON) to CPU INT4

     IntEnable(C674X_MASK_INT4);       //enable the CPU masked INT4

     IntEventSet(SYS_INT_GPIO_B2INT);      //set the EVTFLAG register of GPIO_Bank2

}

/*

 ** \brief   Interrupt Service Routine to be executed on GPIO interrupts.

 **          This disables the bank interrupts, clears the system interrupt

 **          status and pin interrupt status. This also sets flag as 1.

*/

static void GPIOIsr(void)

 {

     /* Disable the interrupts for pins of bank 2 in GPIO.*/

     GPIOBankIntDisable(SOC_GPIO_0_REGS, 2);

 

    /* Clear the system interrupt status in the DSPINTC*/

     IntEventClear(SYS_INT_GPIO_B2INT);

 

    /* Clears the Interrupt Status of GP2[4] in GPIO.*/

     GPIOPinIntClear(SOC_GPIO_0_REGS, 37);

 

    flag = 1;

}

 

 

/*
** \brief  This function checks the insertion status of the MMC/SD card
**         in the device and prints related statements on the serial
**         commuincation console of the external device.
**
*/

/*
** \brief   This function can be called to generate a delay.
*/

static void Delay(volatile unsigned int delay)
{
    while(delay–);
}
void EVMC6748_pinmuxConfig(unsigned int in_reg, unsigned int in_mask, unsigned int in_val)
{
 // unlock the system config registers.
 SYSCONFIG->KICKR[0] = KICK0R_UNLOCK;
 SYSCONFIG->KICKR[1] = KICK1R_UNLOCK;

 // make sure the pinmux register is cleared for the mask bits before
 // setting the value.
 CLRBIT(SYSCONFIG->PINMUX[in_reg], in_mask);
 SETBIT(SYSCONFIG->PINMUX[in_reg], in_val);

 // lock the system config registers.
 SYSCONFIG->KICKR[0] = KICK0R_LOCK;
 SYSCONFIG->KICKR[1] = KICK1R_LOCK;
}

 

/*****************************END OF FILE************************************/

Tony Tang:

这个调用的目的是什么?IntEventSet(SYS_INT_GPIO_B2INT);      //set the EVTFLAG register of GPIO_Bank2

上面程序是基于哪个例子来的?没看到中断向量表,不好说其它的对不对。

另外,观察寄存IFR有没有置位?

赞(0)
未经允许不得转载:TI中文支持网 » 6748外部中断问题
分享到: 更多 (0)