yoje 发表于 2014-4-29 15:36:11

新版本IAR AVR寄存器位在哪个文件定义?

使用官方的TWI_Master,原来的编译器版本是:IAR EWAAVR 2.28a/3.10c,现在用5.40。以下是初始化部分。
void TWI_Master_Initialise(void)
{
TWBR = TWI_TWBR;                                  // Set bit rate register (Baudrate). Defined in header file.
// TWSR = TWI_TWPS;                                  // Not used. Driver presumes prescaler to be 00.
TWDR = 0xFF;                                    // Default content = SDA released.
TWCR = (1<<TWEN)|                                 // Enable TWI-interface and release TWI pins.
         (0<<TWIE)|(0<<TWINT)|                      // Disable Interupt.
         (0<<TWEA)|(0<<TWSTA)|(0<<TWSTO)|         // No Signal requests.
         (0<<TWWC);                                 //
}

编译后,出现如下错误.
Error: identifier "TWEN" is undefined E:\hwh\twi_int\TWI_Master.c 45
Error: identifier "TWIE" is undefined E:\hwh\twi_int\TWI_Master.c 46
Error: identifier "TWINT" is undefined E:\hwh\twi_int\TWI_Master.c 46
Error: identifier "TWEA" is undefined E:\hwh\twi_int\TWI_Master.c 47
Error: identifier "TWSTA" is undefined E:\hwh\twi_int\TWI_Master.c 47
Error: identifier "TWSTO" is undefined E:\hwh\twi_int\TWI_Master.c 47
Error: identifier "TWWC" is undefined E:\hwh\twi_int\TWI_Master.c 48

寄存器位定义在何处?如何引用?

SXH201312 发表于 2014-4-29 16:20:17

试下,打右键
看行不行

yoje 发表于 2014-4-29 16:41:36

SXH201312 发表于 2014-4-29 16:20
试下,打右键
看行不行

没有找到定义。只听到错误提示音。

我现在用一个比较笨的方法,就是把相应汇编里的定义的文件,比如iom88pa.inc的内容,拷出来用:

/* TWAMR */
#define TWAM6 7
#define TWAM5 6
#define TWAM4 5
#define TWAM3 4
#define TWAM2 3
#define TWAM1 2
#define TWAM0 1

/* TWCR */
#define TWINT 7
#define TWEA 6
#define TWSTA 5
#define TWSTO 4
#define TWWC 3
#define TWEN 2
#define TWIE 0

/* TWAR */
#define TWA6 7
#define TWA5 6
#define TWA4 5
#define TWA3 4
#define TWA2 3
#define TWA1 2
#define TWA0 1
#define TWGCE 0

/* TWSR */
#define TWS7 7
#define TWS6 6
#define TWS5 5
#define TWS4 4
#define TWS3 3
#define TWPS1 1
#define TWPS0 0

jack12345 发表于 2014-4-29 15:36:12

IAR 选项
http://www.amobbs.com/thread-4876971-1-1.html

yoje 发表于 2014-4-30 11:38:46

jack12345 发表于 2014-4-29 15:36
IAR 选项
http://www.amobbs.com/thread-4876971-1-1.html

Good!谢谢。
我觉得也应是选项或定义一个宏的问题。但是不够细心,找不到。
页: [1]
查看完整版本: 新版本IAR AVR寄存器位在哪个文件定义?