问题:是否有可能将程序中的完整CAN邮箱的标识符更改为实际上有8多个完整的CAN邮箱?
答:是的,可以在程序中动态地改变完整的CAN邮箱的标识符。可以通过写入CAN TX MSG标识符寄存器来改变标识符。这是一个32位寄存器,用来存储标识符值。在使用标准CAN的情况下,CAN TX MSG寄存器中最重要的11位将包含标识符值。因此,在写入到CAN TX MSG寄存器之前,您必须为标准CAN将其移位21位。类似地,如果使用扩展的CAN,MSB 29位包含标识符值。在这种情况下,您必须在写入寄存器之前移位3位。您可以使用以下函数写入上述寄存器。在使用标准满的情况下,可以使用CythSeTyRG32((Req32))和ChanyTx[邮箱]。TXID,(ID & lt;& 21t);在使用扩展完整的CAN的情况下使用CythSeTrEGR32((Req32*)和ChanyTx [邮箱] .txid,(IDE和lt;3U));其中ID -标准11位标识符;ID-扩展的29位标识符TH。使用上述功能,我们将允许您拥有超过8个完整的CAN消息。附上这篇文章是示例项目。
以上来自于百度翻译
以下为原文
Question: Is it possible to change the identifier of a FULL CAN Mailbox in the program to virtually have more than 8 FULL CAN mailboxes?
Answer: Yes it is possible to change the identifier of the FULL CAN mailbox dynamically in the program. The identifier can be changed by writing to the CAN Tx Msg Identifier register. This is a 32 bit register which is used to store the identifier value.
In case of using a standard CAN, the Most Significant 11 bits of the CAN Tx Msg register will contain the Identifier value. So before writing to the CAN Tx Msg Register you have to shift it by 21 bits for the standard CAN. Similarly if you are using the Extended CAN, the MSB 29 bits contain the identifier value. In this case you have to shift by 3 bits before writing to the register.
You can write to the above mentioned register using the following functions.
In case of using Standard FULL CAN use
CY_SET_REG32((reg32 *)&CAN_TX[mailbox].txid, (ID << 21u));
In case of using Extended FULL CAN use
CY_SET_REG32((reg32 *)&CAN_TX[mailbox].txid, (IDE << 3u));
Where ID – standard 11 bit Identifier; IDE – Extended 29 bit Identifier
Thus using the above function will allow you to have more than 8 FULL CAN messages. Attached along with this post is the example project .