在线时间0 小时
UID342995
注册时间2012-2-20
NXP金币0
该用户从未签到
新手上路

- 积分
- 17
- 最后登录
- 1970-1-1
|
看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)
|
|