/* initialize the CAN at a standard bitrate, interrupts disabled*/ CAN_Init(0, CAN_BITRATE_100K);
/* switch into Loopback+Silent mode (self-test)*/ CAN_EnterTestMode(CAN_TESTR_LBACK | CAN_TESTR_SILENT);
/* configure the message objects*/ CAN_SetUnusedAllMsgObj(); CAN_SetTxMsgObj(CAN_TX_MSGOBJ, CAN_STD_ID, DISABLE); CAN_SetRxMsgObj(CAN_RX_MSGOBJ, CAN_STD_ID, 0, CAN_LAST_STD_ID, TRUE);
/* send a pre-defined data frame*/ (void)CAN_SendMessage(CAN_TX_MSGOBJ, &TxCanMsg[0]);
/* wait until end of transmission*/ CAN_WaitEndOfTx();
/* wait for reception of a data frame*/ while (!CAN_ReceiveMessage(CAN_RX_MSGOBJ, FALSE, &RxCanMsg)) { /* add a time-out handling here, if necessary*/ }
我用上面的代码可以完成自收发工作,但拿掉 CAN_EnterTestMode(CAN_TESTR_LBACK | CAN_TESTR_SILENT);后就不能进行两块板的通讯了,不知道为什么?不知道两块板的通讯是不是要设置什么工作模式? 波特率我两板是一样的
还有就是在RX脚 TX脚都不能看到波形,不知道为什么? 即使在自收发模式下也不能看到波形 |