查看: 2270|回复: 0

[MPC] MPC5604B的CAN接收中断程序

[复制链接]

该用户从未签到

3

主题

7

帖子

0

新手上路

Rank: 1

积分
17
最后登录
1970-1-1
发表于 2013-4-28 20:09:36 | 显示全部楼层 |阅读模式
看datasheet有点看不懂
我直接贴程序和datasheet的语句
下面是datasheet的资料
Each one of the message buffers can be an interrupt source, if its corresponding IMASK bit is set. There
is no distinction between Tx and Rx interrupts for a particular buffer, under the assumption that the buffer
is initialized for either transmission or reception. Each of the buffers has assigned a flag bit in the IFLAG
Registers. The bit is set when the corresponding buffer completes a successful transmission/reception and
is cleared when the CPU writes it to ‘1’ (unless another interrupt is generated at the same time).
                                                      NOTE
It must be guaranteed that the CPU only clears the bit causing the current
interrupt. For this reason, bit manipulation instructions (BSET) must not be
used to clear interrupt flags. These instructions may cause accidental
clearing of interrupt flags which are set after entering the current interrupt
service routine.
好像是说清除中断标志位最好不使用位操作来清除。我是直接采用位操作来清除的,但是原因我不是很清楚。希望有人帮忙解释下。
下面是我写的中断程序,可以运行,但是我不知道以后出现特殊情况会不会导致BUG。

static  void Can0FrameToData(u8  ucIdIndex)
{
    int j, dummy; 
    RxCODE   = CAN_0.BUF[ucIdIndex].CS.B.CODE;    /* Read CODE, ID, LENGTH, DATA, TIMESTAMP */
    stCanRxBuffer[ucIdIndex].ulCanID     = CAN_0.BUF[ucIdIndex].ID.R;
    stCanRxBuffer[ucIdIndex].ulCanLength = CAN_0.BUF[ucIdIndex].CS.B.LENGTH;   
    for (j=0; j < stCanRxBuffer[ucIdIndex].ulCanLength; j++)
    {
        stCanRxBuffer[ucIdIndex].aucCanData[j] = CAN_0.BUF[ucIdIndex].DATA.B[j];
    }  
    stCanRxBuffer[ucIdIndex].ulMesgTime = CAN_0.BUF[ucIdIndex].CS.B.TIMESTAMP;
    dummy = CAN_0.TIMER.R;                /* Read TIMER to unlock message buffers */  
  //  CAN_0.IFRL.R |= (0x00000001)
我知道答案 目前已有0人回答
回复

使用道具 举报

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

本版积分规则

关闭

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

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

GMT+8, 2025-7-21 11:52 , Processed in 0.080155 second(s), 20 queries , MemCache On.

Powered by Discuz! X3.4

Copyright © 2001-2024, Tencent Cloud.

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