IAR问题总结(持续更新)

版权声明:本文为博主原创文章,未经博主允许不得转载。 https://blog.csdn.net/wuhenyouyuyouyu/article/details/77722147

这个帖子持续更新。

一、inline问题

Error[e46]: Undefined external "key_mode_get_key_value" referred in key (xxxx.r87 ) 

用了一个inline函数,结果提示这个,通过查阅资料问题如下:

inline或者#pragma inline建议编译器对紧随其后的函数进行inline处理

#pragma inline = forced 强制编译器对紧随其后的函数进行inline处理

同时这个还和编译器的优先级有关系:

也就是说用了inline,在低优先级下,编译器不一定就把函数作为inline处理。

补充说明:register修饰变量也只是一种建议。

二、调试时候提示:Another EXEC is already running.

IAR for RL78 V1.3用E1调式时候提示这个:

插拔E1不行,板子重新上下电也不行,最后把IAR重启搞定。

三、判断是Debug模式还是Release

NDEBUG
Description This preprocessor symbol determines whether any assert macros you have written in
your application shall be included or not in the built application.
If this symbol is not defined, all assert macros are evaluated. If the symbol is defined,
all assert macros are excluded from the compilation. In other words, if the symbol is:
● defined, the assert code will not be included
● not defined, the assert code will be included
This means that if you write any assert code and build your application, you should
define this symbol to exclude the assert code from the final application.

由上文可知:

NDEBUG  如果定义了,为Release模式,如果没有定义则为debug模式。

四、位域赋值问题
位域赋值时候,是按着从bit0开始对齐到位域宽度:
struct {
uint16_ttBit0   :1;
uint16_t        :7;
uint16_t        :8;
}bit16_t;


uint8_t chTemp;
chTemp          = 0x01;
bit16_t.tBit0   = chTemp;
则赋值后:bit16_t.tBit0为1;

chTemp          = 0xFE;
bit16_t.tBit0   = chTemp;
则赋值后:bit16_t.tBit0为0;



五、BOOL类型变量赋值
bool类型变量赋值,是按着右边的真假值赋值:
uint8_tchTemp;
boolbTemp;

chTemp = 0x00;
bTemp = chTemp;
则bTemp为false;

chTemp = 0xFE;
bTemp = chTemp;
则bTemp为true;
(以chTemp的真假决定)

六、IAR for RL78 模拟软件复位功能

由于RL78芯片没有软件复位功能,但是可以通过复位选项模拟软件复位。

复位源:

有手册可知,当执行非法指令0xFF时候就可以产生复位。

有两种方法,把变量赋值为0xFF,强制转换为函数指针。

或者用汇编指令:asm("db 0xFF");

我用第二种方法,测试可用。

七、union的0占位符问题

我一直以为位域中的0宽度占位符是不跨字节的,因此我定义了下面一个结构体:

debug发现,当给tSelectLocdorLed赋值的时候,tSlectItem值并没有改变,

因此我想是不是0占位符把后面的bits全占了。因此把所有的0都修改为本子节

实际未使用数,再debug发现正常了,我查了半天C99,也么有找到相关说明,

回头找到了,再发上来。

八、自动获得工程路径和安装路径

程序配置时候,可以把和工程相关的配置为相对路径,如:$PROJ_DIR$\linker\lnkr5f100fe.xcl

                          可以把和工具相关的配置为相对路径,如:$TOOLKIT_DIR$\LIB\

猜你喜欢

转载自blog.csdn.net/wuhenyouyuyouyu/article/details/77722147