带中断MSP430G2553控制程序和错误处理

MSP430G2553板LED在P1.0和P1.6,和P1.3连着一个按钮开关,可以对其进行中断编程。

#include "MSP430G2553.h"
int ms,k,i;
char jj[]={
           0x01,0x00,0x40,0x00,0x01,0x00,0x40,0x00,0x40,0x00,0x01,
           0x00,0x40,0x00,0x01,0x00,0x41,0x00,0x41,0x00,0x41,0x00
          };
void delay(int ms)
{
  while(ms--)
   {
    for(i=0;i<120;i++);
   }
}
int main( void )
{
  // Stop watchdog timer to prevent time out reset
  WDTCTL = WDTPW + WDTHOLD;
  P1DIR |=BIT6+BIT0;
  P1IE  |=BIT3;
  P1IES |=BIT3;
  P1IFG &=~BIT3;
  _BIS_SR(GIE);
  while(1)
  {
    for(k=0;k<22;k++)
    {
     P1OUT=jj[k];
     delay(300);
    }
  }
}
 #pragma   vector=PORT1_VECTOR
 __interrupt void zhansan(void)
      {
      
        for(k=0;k<5;k++)
        {
           P1OUT |=BIT6+BIT0;
           delay(1000);
           P1OUT &=~(BIT6+BIT0);
           delay(1000);
        }
        P1IFG &=~BIT3;
      }

IAR调试msp430时出现警告提示:

The stack plug-n failed to set a breakpoint on "main". The Stack window will not be able to display stack contents. (You can change this setting in the Tool>Options dialog box.)

需要进行以下配置:

 1. iar->options->linker->output->format;
    选择 Debug information for c-SPY选项

 2. iar->Tools->options->stack->去掉选项“stack pointer(s) not valid until program reaches”

永不止步步 发表于11-22 08:53 浏览65535次
分享到:

已有0条评论

暂时还没有回复哟,快来抢沙发吧

添加一条新评论

只有登录用户才能评论,请先登录注册哦!

话题作者

永不止步步
金币:67410个|学分:306117个
立即注册
畅学电子网,带你进入电子开发学习世界
专业电子工程技术学习交流社区,加入畅学一起充电加油吧!

x

畅学电子网订阅号