查看: 4731|回复: 5

[求助] LPC4078使用CAN2时程序卡死在中断里

[复制链接]

该用户从未签到

1

主题

3

帖子

0

新手上路

Rank: 1

积分
19
最后登录
2021-10-17
发表于 2021-10-5 17:38:53 | 显示全部楼层 |阅读模式
各位大佬,我在一个项目中使用LPC4078芯片时遇到这样的一个问题:主板使用CAN2接口与其他控制板进行通讯,程序有时候运行一段时间会卡死,即主程序不跑了,经过仿真发现程序卡死在CAN中断程序里,即一直进中断程序,主程序跑不了。出现卡死时发现ICR寄存器的值为0xF30000,请问社区上的大佬有遇见这种情况吗?有经验的大佬可以帮忙分析一下噢,感谢!!!
我知道答案 目前已有5人回答
回复

使用道具 举报

  • TA的每日心情
    奋斗
    前天 20:19
  • 签到天数: 1849 天

    连续签到: 4 天

    [LV.Master]伴坛终老

    203

    主题

    3万

    帖子

    64

    超级版主

    Rank: 8Rank: 8

    积分
    112633
    最后登录
    2025-7-22
    发表于 2021-10-5 21:16:10 | 显示全部楼层
    进入中断以后清除相应的中断标志了吗? 1.png 2.png 3.png 4.png 9.png 7.png 5.png 6.png 8.png 10.png
    该会员没有填写今日想说内容.
    回复 支持 反对

    使用道具 举报

    该用户从未签到

    1

    主题

    3

    帖子

    0

    新手上路

    Rank: 1

    积分
    19
    最后登录
    2021-10-17
     楼主| 发表于 2021-10-6 11:40:19 | 显示全部楼层
    ICR寄存器只读的,手册上说读一下就会自动清除的,CAN中断函数里每进一次就会读一次ICR寄存器,按道理来说是清除了的。
    回复 支持 反对

    使用道具 举报

    该用户从未签到

    712

    主题

    6371

    帖子

    0

    超级版主

    Rank: 8Rank: 8

    积分
    24915
    最后登录
    2025-7-23
    发表于 2021-10-9 16:45:21 | 显示全部楼层
    是不是CAN 总线错误:
    20:16 ERRBIT4_0 Error Code Capture: when the CAN controller detects a bus error, the location of
    the error within the frame is captured in this field. The value reflects an internal
    state variable, and as a result is not very linear:
    00011 = Start of Frame
    00010 = ID28 ... ID21
    00110 = ID20 ... ID18
    00100 = SRTR Bit
    00101 = IDE bit
    00111 = ID17 ... 13
    01111 = ID12 ... ID5
    01110 = ID4 ... ID0
    01100 = RTR Bit
    01101 = Reserved Bit 1
    01001 = Reserved Bit 0
    01011 = Data Length Code
    01010 = Data Field
    01000 = CRC Sequence
    11000 = CRC Delimiter
    11001 = Acknowledge Slot
    11011 = Acknowledge Delimiter
    11010 = End of Frame
    10010 = Intermission
    Whenever a bus error occurs, the corresponding bus error interrupt is forced, if
    enabled. At the same time, the current position of the Bit Stream Processor is
    captured into the Error Code Capture Register. The content within this register is
    fixed until the user software has read out its content once. From now on, the
    capture mechanism is activated again, i.e. reading the CANxICR enables
    another Bus Error Interrupt.


    回复 支持 反对

    使用道具 举报

    该用户从未签到

    1

    主题

    3

    帖子

    0

    新手上路

    Rank: 1

    积分
    19
    最后登录
    2021-10-17
     楼主| 发表于 2021-10-11 23:04:46 | 显示全部楼层
    小恩GG 发表于 2021-10-9 16:45
    是不是CAN 总线错误:

    对,感觉是CAN总线错误了,但是重新初始化CAN也解决不了问题,还是会一直进中断,请问有什么好的解决办法吗?
    回复 支持 反对

    使用道具 举报

    该用户从未签到

    712

    主题

    6371

    帖子

    0

    超级版主

    Rank: 8Rank: 8

    积分
    24915
    最后登录
    2025-7-23
    发表于 2021-10-20 15:56:16 | 显示全部楼层
    尝试先把总线错误中断关掉。
    如果确定是总线错误中断,查看发的数据格式或者其它哪里错了。
    检查代码是否误把某些中断置位了。
    回复 支持 反对

    使用道具 举报

    您需要登录后才可以回帖 注册/登录

    本版积分规则

    关闭

    站长推荐上一条 /3 下一条

    Archiver|手机版|小黑屋|恩智浦技术社区

    GMT+8, 2025-7-24 00:19 , Processed in 0.098582 second(s), 27 queries , MemCache On.

    Powered by Discuz! X3.4

    Copyright © 2001-2024, Tencent Cloud.

    快速回复 返回顶部 返回列表