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.

cc3200外部中断

Other Parts Discussed in Thread: CC3200, ENERGIA

大家好,我的情况如下

1.板子是cc3200 launchpad

2.代码的目标功能是通过板子的D4引脚(D4引脚已经和一个传感器连接),触发外部中断,并在中断函数中输出字符串"Hello"

3.现在遇到的问题是无法触发外部中断

(备注: 上述传感器在Arduino上做过实验,正常工作,已证实不是传感器问题)

下面是我参考SDK相关例程写出的cc3200外部中断代码,还望TI员工和各位伙伴指点是哪里出了问题,感激不尽。

void pin_mux_config(){

    // 使能GPIOA1时钟
    PRCMPeripheralClkEnable(PRCM_GPIOA1, PRCM_RUN_MODE_CLK);
    PRCMPeripheralReset(PRCM_GPIOA1);
    // 设置引脚4为GPIO模式, 标准模式, 2ma
    PinModeSet(PIN_04, PIN_MODE_0);
    PinConfigSet(PIN_04, PIN_STRENGTH_2MA, PIN_TYPE_STD);
    // 设置成输入, 引脚4对应GPIOA1的pin5
    GPIODirModeSet(GPIOA1_BASE, GPIO_PIN_5, GPIO_DIR_MODE_IN);
    // 设置成上升沿触发中断
    GPIOIntTypeSet(GPIOA1_BASE, GPIO_PIN_5, GPIO_RISING_EDGE);
    // 设置中断处理函数
    GPIOIntRegister(GPIOA1_BASE, interrupt_func);
    // 使能中断
    GPIOIntEnable(GPIOA1_BASE, GPIO_INT_PIN_5);
}


void setup() {
    Serial.begin(9600);
    pin_mux_config();
}

void loop() {
    Serial.println(" Loop...");
    delay(1000);
}

void interrupt_func() {

    Serial.println("Hello");

}

  • 能否确认当按键电平发生变化时,CC3200是否进入了

    void interrupt_func() 

    {

        Serial.println("Hello");     可以在这里打个断点,通过仿真模式下进行验证

    }

    这个函数? 能否排除是串口信息输出是否有问题?

    //
    // Set Interrupt Type for GPIO
    //
    MAP_GPIOIntTypeSet(GPIOA1_BASE,GPIO_PIN_5,GPIO_FALLING_EDGE); //对应PIN_04物理引脚
    MAP_GPIOIntTypeSet(GPIOA2_BASE,GPIO_PIN_6,GPIO_FALLING_EDGE); //对应PIN_15物理引脚

    //
    // Store Interrupt handlers
    // 回调函数入口首地址
    g_pAudioInControlHdl = pAudioInControl; //MICStartStopControl
    g_pAudioOutControlHdl = pAudioOutControl; //SpeakerStartStopControl

    //
    // Register Interrupt handler
    // 在操作系统中注册中断
    lRetVal = osi_InterruptRegister(INT_GPIOA1,(P_OSI_INTR_ENTRY)MICButtonHandler,INT_PRIORITY_LVL_1); //<1>按键后发生MICButtonHandler()中断
    ASSERT_ON_ERROR(lRetVal);

    lRetVal = osi_InterruptRegister(INT_GPIOA2,(P_OSI_INTR_ENTRY)SpeakerButtonHandler,INT_PRIORITY_LVL_1); //<2>按键后发生SpeakerButtonHandler()中断
    ASSERT_ON_ERROR(lRetVal);

    //
    // Enable Interrupt
    // 使能GPIO中断,当按键中断发生后会进入相应的MICButtonHandler()或SpeakerButtonHandler()
    // 在该中断入口函数中会调用回调函数g_pAudioInControlHdl或g_pAudioOutControlHdl-->MICStartStopControl或者SpeakerStartStopControl写入消息队列中
    MAP_GPIOIntClear(GPIOA1_BASE,GPIO_PIN_5);
    MAP_GPIOIntEnable(GPIOA1_BASE,GPIO_INT_PIN_5);
    MAP_GPIOIntClear(GPIOA2_BASE,GPIO_PIN_6);
    MAP_GPIOIntEnable(GPIOA2_BASE,GPIO_INT_PIN_6);

  • 十分感谢Terry Han的热心帮助。因为我用的是energia来开发的,请问在energia下可以怎么做?

  • 建议可以到https://e2e.ti.com/论坛看看energia的相关问题讨论