前段时间一直用CCS,但是机器太差(06 年的笔记本),启动一次CCS的调试需要近2分钟。。。。。:funk: 于是换IAR5.10,速度确实提升不少。。。。。
今天使用IAR新建的工程调试MSP430的IO中断程序。整个中断程序如下:
//#include "msp430.h"
//#include "io430.h"
#include "io430G2211.h"
#include "in430.h"
void delay()
{
int i;
for(i=0;i<6553;i++);
for(i=0;i<6553;i++);
}
void blink(void)
{
P2OUT = 0x00;
delay();
P2OUT = 0xFF;
delay();
}
int main( void )
{
// Stop watchdog timer to prevent time out reset
WDTCTL = WDTPW + WDTHOLD;
P2SEL = 0x00; // P1.0 = TACLK input, P1.7 = CAOUT
P2DIR = 0xc0;
P2OUT = 0x00;
P1DIR = 0x00;
P1SEL = 0x00;
P1REN = 0x08;
P1OUT = 0x08;
P1IE = 0xff; //interrupt enable
P1IES = 0xff; //set the high to low interrupt the P1.3
P1IFG=0;//CLEAR INTERRUPT AT P1.3
_BIS_SR(LPM0_bits+GIE);
//GIE = aa;;
while(1);
}
#pragma vector=PORT1_VECTOR
__interrupt void P1VECTOR(void)
{
//if(P1IFG&0x08!=0)
// {
unsigned j=0;
while(j<30)
{
blink();
j++;
}
P1IFG=0;//CLEAR INTERRUPT AT P1.3
}
简单说来,该程序使用P1.3作为IO中断输入,当有按键触发中断时跳入到中断处理函数中,使LED灯闪烁30次。。。。
P1IE = 0xff; //interrupt enable
P1IES = 0xff; //set the high to low interrupt the P1.3
P1IFG=0;//CLEAR INTERRUPT AT P1.3
_BIS_SR(LPM0_bits+GIE); //open interrupt flag in SR reg.
最关键的也就是这4句话,前面三句表示的是打开对应的IO中断,最后一句是置SR寄存器中的GIE位,打开430的中断总开关。
也就是这句话出问题了,IAR弹出错误:
Error[e46]: Undefined external "_BIS_SR" referred in main ( F: empiarbeginDebugObjmain.r43 )
也就是说_BIS_SR没有定义。。。但是很多官方的例子里面都是使用_BIS_SR的啊!问题出在哪呢??看到工程上部的4个头文件
//#include "msp430.h"
//#include "io430.h"
#include "io430G2211.h"
#include "in430.h"
IAR新建工程时,默认使用的头文件是IO430.h,当我们把这个头文件换成msp430.h上述错误就消失了,中断正常响应。。。
于是我们继续查找这两个头文件的不同,发现msp430.h中会包含IN430.H头文件,而IO430.H中没有包含IN430.H这个文件。打开IN430.H,哈哈,我们要找的东西全在里面,除了刚才说的_BIS_SR外,我们还可以使用_EINT() 等CCS中常用的函数了。。
#ifndef __IN430_H
#define __IN430_H
#ifndef _SYSTEM_BUILD
#pragma system_include
#endif
#include "intrinsics.h"
#pragma language=save
#pragma language=extended
/*
* Deprecated intrinsic functions.
*/
#ifdef __cplusplus
extern "C"
{
#endif
/* Deprecated, please use "__bis_SR_register" instead. (If the
* return value of this intrinsic is used, you can also use
* "__get_SR_register".) */
__intrinsic unsigned short _BIS_SR(unsigned short);
/* Deprecated, please use "__bic_SR_register" instead. (If the
* return value of this intrinsic is used, you can also use
* "__get_SR_register".) */
__intrinsic unsigned short _BIC_SR(unsigned short);
/* Deprecated, please use "__bis_SR_register_on_exit" instead. (If
* the return value of this intrinsic is used, you can also use
* "__get_SR_register".) */
__intrinsic unsigned short _BIS_SR_IRQ(unsigned short);
/* Deprecated, please use "__bic_SR_register_on_exit" instead. (If
* the return value of this intrinsic is used, you can also use
* "__get_SR_register".) */
__intrinsic unsigned short _BIC_SR_IRQ(unsigned short);
/* Deprecated, please use the #pragma directive "bis_nmi_ie1"
* instead. */
__intrinsic unsigned short _BIS_NMI_IE1(unsigned short);
#ifdef __cplusplus
}
#endif
/*
* Convenience macros mapping old names to new.
*/
/* Deprecated, please use "__disable_interrupt" instead. */
#define _DINT() __disable_interrupt()
/* Deprecated, please use "__enable_interrupt" instead. */
#define _EINT() __enable_interrupt()
/* Deprecated, please use "__no_operation" instead. */
#define _NOP() __no_operation()
/* Deprecated, please use "__op_code" instead. */
#define _OPC(x) __op_code(x)
/* Deprecated, please use "__swap_bytes" instead. */
#define _SWAP_BYTES(x) __swap_bytes(x)
/* Deprecated, please use the keyword "__monitor" instead. */
#define monitor __monitor
/* Deprecated, please use the keyword "__no_init" instead. */
#define no_init __no_init
#pragma language=restore
#endif /* __IN430_H */
友情提示: 此问题已得到解决,问题已经关闭,关闭后问题禁止继续编辑,回答。
一周热门 更多>