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.

[参考译文] MSP430F5438A:端口中断

Guru**** 2539500 points
Other Parts Discussed in Thread: MSP430F5438A

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

https://e2e.ti.com/support/microcontrollers/msp-low-power-microcontrollers-group/msp430/f/msp-low-power-microcontroller-forum/998489/msp430f5438a-port-interrupt

器件型号:MSP430F5438A

您好!

我们在运行 MSP430F5438A 的定制板上遇到了伪 GPIO 中断问题。
大多数端口1和2引脚启用了 PxIE 并根据连接的外设不同具有不同的 PxIES。
在~1KHz 时切换引脚 P1.2会加速/导致两个端口上设置了多个 IFG 的问题。

通过测试/记录系统、我们在问题发生时发现了以下伪代码序列。

//////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////

volatile unsigned int g_cnt = 0;
volatile unsigned char g_save_1 = 0;
volatile unsigned char g_save_2 = 0;

// 1. 在这里、主器件进入低功耗模式
_bis_SR_register (LPM3_bits + GIE);

// 2. 端口1 IRQ
_interrupt void Port1 (void)

 IF (P1IFG & 0x04)
 {
  g_cnt++;
  P1IFG &=~0x04;
 }
 其他
 {
  // P1注册表此时:
  // in=0x32、out=0x32、DIR=0x00、SEL=0x00、REN=0x7A、 IES=0x10、IE=0x3E、IFG=0x11

  G_SAVE_1 =(P1IFG 和 P1IE);
  P1IFG = 0;
  _low_power_mode_off_in_exit ();

// 3. 端口2 IRQ
_interrupt void Port2 (void)

 // P2注册表此时:
 // in=0xAA out=0xAA DIR=0x40 SEL=0x00 REN=0xBF IES=0xAA IE=0xBF IFG=0xAA

 G_SAVE_2 =(P2IFG 和 P2IE);

 P2IFG = 0;
 _low_power_mode_off_in_exit ();

// 4. 主系统从低功耗模式返回到这里... 端口1和2中断例程都已执行
如果(g_save_1 || g_save_2)

 //采取行动...

//////////////////////////////////////////////////////////////////////////////////////////////////////////////

通过测量、我们无法在引脚上看到会解释多个 PxIFG 的任何实际电平转换
是否有人建议会导致此问题的原因?

我们有两种硬件设计在原理图上完全相同(达到99%)、但在布局上大多不同。
到目前为止,问题只在一个电路板设计上可见...

此致、TMA

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

    您好!

    您是否在用于中断的引脚上启用了中断? 此外、是否在为每个 IO 引脚启用中断后立即清除中断标志、是否清除 ISR 中的中断标志? 根据用户指南、写入 P1OUT、P1DIR、P1REN、P2OUT、 P2DIR 或 P2REN 可导致相应的 P1IFG 或 P2IFG 标志置1。

    /* --COPYRIGHT--,BSD_EX
     * Copyright (c) 2012, Texas Instruments Incorporated
     * All rights reserved.
     *
     * 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.
     *
     *******************************************************************************
     * 
     *                       MSP430 CODE EXAMPLE DISCLAIMER
     *
     * MSP430 code examples are self-contained low-level programs that typically
     * demonstrate a single peripheral function or device feature in a highly
     * concise manner. For this the code may rely on the device's power-on default
     * register values and settings such as the clock configuration and care must
     * be taken when combining code from several examples to avoid potential side
     * effects. Also see www.ti.com/grace for a GUI- and www.ti.com/msp430ware
     * for an API functional library-approach to peripheral configuration.
     *
     * --/COPYRIGHT--*/
    //******************************************************************************
    //  MSP430F543xA Demo - Software Port Interrupt Service on P1.4 from LPM4 with
    //                    Internal Pull-up Resistance Enabled
    //
    //  Description: A hi "TO" low transition on P1.4 will trigger P1_ISR which,
    //  toggles P1.0. P1.4 is internally enabled to pull-up. Normal mode is
    //  LPM4 ~ 0.1uA. LPM4 current can be measured with the LED removed, all
    //  unused Px.x configured as output or inputs pulled high or low.
    //  ACLK = n/a, MCLK = SMCLK = default DCO
    //
    //               MSP430F5438A
    //            -----------------
    //        /|\|              XIN|-
    //         | |                 |
    //         --|RST          XOUT|-
    //     /|\   |                 |
    //      --o--|P1.4         P1.0|-->LED
    //     \|/
    //
    //   M. Morales
    //   Texas Instruments Inc.
    //   June 2009
    //   Built with CCE Version: 3.2.2 and IAR Embedded Workbench Version: 4.11B
    //******************************************************************************
    
    #include <msp430.h>
    
    int main(void)
    {
      WDTCTL = WDTPW + WDTHOLD;                 // Stop watchdog timer
      P1DIR |= 0x01;                            // Set P1.0 to output direction
      P1REN |= 0x10;                            // Enable P1.4 internal resistance
      P1OUT |= 0x10;                            // Set P1.4 as pull-Up resistance
      P1IE |= 0x10;                             // P1.4 interrupt enabled
      P1IES |= 0x10;                            // P1.4 Hi/Lo edge
      P1IFG &= ~0x10;                           // P1.4 IFG cleared
    
      __bis_SR_register(LPM4_bits + GIE);       // Enter LPM4 w/interrupt
      __no_operation();                         // For debugger
    }
    
    // Port 1 interrupt service routine
    #if defined(__TI_COMPILER_VERSION__) || defined(__IAR_SYSTEMS_ICC__)
    #pragma vector=PORT1_VECTOR
    __interrupt void Port_1(void)
    #elif defined(__GNUC__)
    void __attribute__ ((interrupt(PORT1_VECTOR))) Port_1 (void)
    #else
    #error Compiler not supported!
    #endif
    {
      P1OUT ^= 0x01;                            // P1.0 = toggle
      P1IFG &= ~0x010;                          // P1.4 IFG cleared
    }