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.

[参考译文] MSP430FR6989:中断标志置1、但不进入 ISR

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

https://e2e.ti.com/support/microcontrollers/msp-low-power-microcontrollers-group/msp430/f/msp-low-power-microcontroller-forum/902598/msp430fr6989-interrupt-flag-set-but-not-going-into-isr

器件型号:MSP430FR6989

您好!  

当我启动以下代码并将其中一个引脚3.0或3.1 (或3.2)拉低时、程序不会进入中断子例程、尽管(通过 Code Composer 的调试器查看寄存器时)已为这些特定引脚设置了 P3IFG (老实说、所有1都是这样、因此当拉低1个引脚时-> P3IFG=0xFF)。 我不知道为什么会发生这种情况。
有人知道吗?  

#include 
#include "ram_module.h"

/**
* main.c
*/
int main (void)
{
PM5CTL0 &=~LOCKLPM5;
WDTCTL = WDTPW | WDTHOLD;//停止看门狗定时器

//声明所有引脚
//控制端口
P3DIR |= 0b00000000;//第三个端口是 CSn 端口,这是只读
的 P3IE |= 0b00000111;
P3IES |= 0x03; //在前两个引脚
P3IFG &=~0x03上从高电平到低电平;//清除标志

//地址端口(端口1:5、端口8:4、端口9:7),只读
P1DIR |= 0b00000000;
P8DIR |= 0b00000000;
P9DIR |= 0b00000000;
_ no_operation (
_);_ no_operation (_)
//数据端口
P2DIR |= 0x00;
__NO_OPERATION ();
__NO_OPERATION ();

返回0;
}/*


每个端口只有一个矢量,只能写入一个 ISR。
*要区分一个中断矢量的不同中断源
、*在本例中为不同的端口引脚、您必须检查 ISR 中的 IFG 位。
//

#if defined (__TI_Compiler_version__)|| defined (__IAR_systems_icc_)
#pragma vector=PORT3_vector
__interrupt void Port_3 (void)
#elif defined (__GNU__)
void __attribute__((interrupt (PORT3_vector)))) Port_3 (void

编译器#error!
#endif
{
uint16_t volatile * const address =(uint16_t *) getAddress ();
//uint16_t* data =空;
//data =地址;
if (P3IFG&BIT0){
//P1OUT^= BIT0;数据被写入这个 MPC
*地址= P2IN;
}
if (P3IFG&BIT1){//可以是另一个
//P1OUT^=BIT1;从 MPC 读取数据
P2DIR &= 0xFF;//置于写入模式
P2OUT =*地址;
//address =地址+ 8;
//P2OUT =*地址;
__no_operation();
P2DIR &= 0x00;//置于读取模式
}

P3IFG=0;//将所有标志设置为0

}

此致、  

Yannick

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

    您好、Yannick、

    您似乎没有启用全局中断 GIE。

    使用其中一个

    enable_interrupts ();

     _bis_SR_register (GIE);