打印

移植CANFestival到c8051f5xx上的问题

[复制链接]
5018|4
手机看帖
扫描二维码
随时随地手机跟帖
跳转到指定楼层
楼主
ichaoer|  楼主 | 2012-9-25 07:14 | 只看该作者 |只看大图 回帖奖励 |倒序浏览 |阅读模式
本帖最后由 ichaoer 于 2012-9-25 09:07 编辑

我试着在c8051f5xx上去实现CANopen,CANFestival的协议栈,用KEIL的环境。底层写好之后,消除编译错误告警之后,一个奇怪的问题出现了。程序不能跳转


到main。


在startup.a51中如下这一句
                LJMP    ?C_START
对应的反汇编是 C:0xCFCD    02D00B   LJMP     C: D00B 这条自循环语句。程序跑到这条LJMP语句(用仿真器)跑飞了。为什么?
C:0xCFCD    02D00B   LJMP     C: D00B
C:0xCFD0    02C457   LJMP     main(C:C457)
C:0xCFD3    E4       CLR      A


其实跳转到main的语句就在自循环语句的下一句。为什么呢?是设置的问题还是?




keil中的设置如下:
Memory Model 和Code Rom 都是large模式
BL51 locate中设置Xdata:0x0000-0x0FFF


使用模拟器可以跳转到main,使用仿真器执行完跳转就跑到一个奇怪的地方,跑飞了。




Starup.a51 中设置如下
; <h> Stack Space for reentrant functions in the LARGE model.      
;  <q> XBPSTACK: Enable LARGE model reentrant stack
;     <i> Stack space for reentrant functions in the LARGE model.
XBPSTACK        EQU     1       ; set to 1 if large reentrant is used.
;  <o> XBPSTACKTOP: End address of LARGE model stack <0x0-0xFFFF>
;     <i> Set the top of the stack to the highest location.
XBPSTACKTOP     EQU     0x0FFF +1   ; default 0FFFFH+1
; </h>
;

1code.png (19.48 KB )

1code.png

2target.png (20.87 KB )

2target.png

3bl51.png (17.13 KB )

3bl51.png

debug.png (17.97 KB )

debug.png

相关帖子

沙发
阿南| | 2012-9-25 09:11 | 只看该作者
把模拟和仿真器时的D00B地址的内容都放出来看看

使用特权

评论回复
板凳
ichaoer|  楼主 | 2012-9-25 10:24 | 只看该作者
刚才技术支持给我回电子邮件了,说是,我在startup.a51中 XBPSTACK  设置为1,XDATALEN设置为0X1000的缘故。
可是我的协议栈需要用仿真栈,XBPSTACK  必须设置,怎么办呢?。另外他给我加了如下几行代码:


STARTUP1:
                anl   PCA0MD, #NOT(040h)
                orl   VDM0CN , #080h
                orl   RSTSRC, #002h

IF IDATALEN <> 0


; <h> Stack Space for reentrant functions in the LARGE model.      
;  <q> XBPSTACK: Enable LARGE model reentrant stack
;     <i> Stack space for reentrant functions in the LARGE model.
XBPSTACK        EQU     0       ; set to 1 if large reentrant is used.
;  <o> XBPSTACKTOP: End address of LARGE model stack <0x0-0xFFFF>
;     <i> Set the top of the stack to the highest location.
XBPSTACKTOP     EQU     0x0FFF +1   ; default 0FFFFH+1
; </h>


另外
由于在外部ram存储大量的数据是否意味着我们也需要做如下修改?
XDATALEN        EQU     0x1000

使用特权

评论回复
地板
阿南| | 2012-9-25 10:56 | 只看该作者
楼主设置XBPSTACK=1使在大模式下,所以使有外部RAM,那么外RAM的实践起始地址和容量是多少?是否为0x1000?如果  XDATALEN设置成0x1000。
楼主 XBPSTACKTOP 设置在多少? 0x0FFF +1?

使用特权

评论回复
5
ichaoer|  楼主 | 2012-9-25 11:19 | 只看该作者
芯片的外部RAM的小为4k,内部flash为64k,所以我想把XBPSTACK=1, 外部RAM的地址是0-0x1000,所以我把XBPSTACKTOP 设置在0x1000 = 0xFFF+1

使用特权

评论回复
发新帖 我要提问
您需要登录后才可以回帖 登录 | 注册

本版积分规则

0

主题

4

帖子

1

粉丝