关于KEIL V4.24.00.0编译提示L121错误的解决方案

前些天 帮一朋友测试代码,基于R8051,使用V4.02编译不报错误,使用V4.24.00.00报L121错误

*** ERROR L121: IMPROPER FIXUP
    MODULE:  .\BIN\main.obj (MAIN)
    SEGMENT: ?PR?MAIN?MAIN
    OFFSET:  00CEH
*** ERROR L121: IMPROPER FIXUP
    MODULE:  .\BIN\main.obj (MAIN)
    SEGMENT: ?PR?MAIN?MAIN


对于L121,KEIL官网上给出的解释是这样的

*** Error L121 Improper Fixup

Module: filename (module-name)

Segment: segment-name

Offset: address


Description	
After evaluation of absolute fix-ups, an address is not accessible. The improper address along with the specific module name, partial segment, and segment address are displayed. The fix-up command is not processed. This error occurs when an instruction tries do make a memory access that is outside the scope of this instruction (for example MOVX @Ri outside of the PDATA page, or ACALL outside of the 2KB code memory block).


并没有发现有用的线索

调试代码,查看编译的汇编文件和映射文件,看到每一条指令都指向定义bdata的变量

OFDM_PHY_ext   bit     bdata   bLib_RxPlcEnd;
OFDM_PHY_ext   bit     bdata  RX_BUSY;
OFDM_PHY_ext   bit     bdata  TX_BUSY;
Comm_ext bit bdata bCommRxEnd;
Comm_ext bit bdata bCommRxstart;

注释掉bdata,编译通过。说明不是软件本身的缺陷


查看帮助文件,查找bdata

一篇文章中这样写的

The variables ibase and bary are bit-addressable. Therefore, the individual bits of these variables may be directly accessed and modified. Use the sbit keyword to declare new variables that access the bits of bdata variables. For example:

sbit mybit0 = ibase ^ 0;      /* bit 0 of ibase */
sbit mybit15 = ibase ^ 15;    /* bit 15 of ibase */

sbit Ary07 = bary[0] ^ 7;     /* bit 7 of bary[0] */
sbit Ary37 = bary[3] ^ 7;     /* bit 7 of bary[3] */
The above example represents declarations, not assignments to the bits of the ibase and bary bdata variables. The expression following the carat symbol ('^') in the example specifies the position of the bit to access with this declaration. This expression must be a constant value.

The range depends on the type of the base variable included in the declaration. The range is:

0-7 for char and unsigned char, 0-15 for int, unsigned int,
short, and unsigned short, and
0-31 for long and unsigned long.

并没有定义bit类型的bdata。因此定义成char。

OFDM_PHY_ext   char     bdata   bLib_RxPlcEnd;
OFDM_PHY_ext   char     bdata  RX_BUSY;
OFDM_PHY_ext   char     bdata  TX_BUSY;
Comm_ext char bdata bCommRxEnd;
Comm_ext char bdata bCommRxstart;

总结:

版本升级,对代码的规范性要求越来越严格。


评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值