各位高手,小弟正在开发DSP处理器与ARM处理器通过CAN总线通信的程序,在开发DSP处理器接收CAN消息的程序的时候,使用16~31邮箱作为接收邮箱。系统运行后,依次读取16~31编号的邮箱内容,发现未读出任何数据,请教其中的原因。部分代码如下:
主循环代码:
while (1)
{
//Read from Receive mailboxes and begin checking for data */
for(j=16; j<32; j++) // Read & check 16 mailboxes
{
//mailbox_read(16); //从接收邮箱0中读出8字节消息负载和消息ID This funcreads the indicated mailbox data
DELAY_US (200);
mailbox_read(j);
//mailbox_check(TestMbox1,TestMbox2,TestMbox3); //校验接收到的消息是否正确 Checks thereceived data
printf ("\n TestMbox1 = %02x \n", TestMbox1);
printf ("\n TestMbox2 = %02x \n", TestMbox2);
}
}
从邮箱中读出消息的函数:
void mailbox_read(int16 MBXnbr)
{
volatilestructMBOX *Mailbox;
Mailbox = &ECanbMboxes.MBOX0 + MBXnbr;
TestMbox1 = Mailbox->MDL.all;// = 0x9555AAAn (n is the MBX number)
TestMbox2 = Mailbox->MDH.all;// = 0x89ABCDEF (a constant)
TestMbox3 = Mailbox->MSGID.all;// = 0x9555AAAn (n is the MBX number)
}