ZHCAF96 April 2025 MSPM0G3506 , MSPM0G3507 , MSPM0G3518 , MSPM0G3519
在 SDK 中,TX 在当前演示项目中配置为缓冲模式。下述讨论了如何在缓冲器模式下使用 TX。
DL_MCAN_TxBufElement txMsg;
/* Initialize message to transmit. */
/* Identifier Value. */
txMsg.id = ((uint32_t)(0x4)) << 18U;
/* Transmit data frame. */
txMsg.rtr = 0U;
/* 11-bit standard identifier. */
txMsg.xtd = 0U;
/* ESI bit in CAN FD format depends only on error passive flag. */
txMsg.esi = 0U;
/* Transmitting 4 bytes. */
txMsg.dlc = 1U;
/* CAN FD frames transmitted with bit rate switching. */
txMsg.brs = 1U;
/* Frame transmitted in CAN FD format. */
txMsg.fdf = 1U;
/* Store Tx events. */
txMsg.efc = 1U;
/* Message Marker. */
txMsg.mm = 0xAAU;
/* Data bytes. */
txMsg.data[0] = LED_STATUS_ON;
/* Write Tx Message to the Message RAM. */
DL_MCAN_writeMsgRam(MCAN0_INST, DL_MCAN_MEM_TYPE_BUF, 0U, &txMsg);
/* Add request for transmission. */
DL_MCAN_TXBufAddReq(MCAN0_INST, 0U);
首先,通过调用 DL_MCAN_writeMsgRam(),将 TX 消息以缓冲区类型与缓冲区编号保存到消息 RAM 中。然后,使用添加请求通过调用 DL_MCAN_TXBufAddReq() 与此消息的缓冲区编号信息一起传输。