Hi team:
I use the can_pal0 and can_pan2 module in PE , and they can send and receive data with standard ID each other. Then I change the CAN_MSG_ID_STD to CAN_MSG_ID_EXT, and CAN ID from 0x01 to 0x10001, but CAN0 cannot receive data sent by CAN2.
Here are the codes for CANx initial and send, please help me check them.
解決済! 解決策の投稿を見る。
Hi@fedora
There is no problem with receiving. The error is that you are not sending an extended frame.
place "CAN_ConfigTxBuff()" before "CAN_Send()"
"
{
can_message_t Tx_msg = {
.cs = 0U,
.id = 0x10001,
.data[0] = 0x20,
.data[1] = 0x21,
.data[2] = 0x22,
.data[3] = 0x23,
.data[4] = 0x24,
.data[5] = 0x25,
.data[6] = 0x26,
.data[7] = 0x27,
.length = 8
};
can_buff_config_t Tx_buffCfg = {
.enableFD = false,
.enableBRS = false,
.fdPadding = 0U,
.idType = CAN_MSG_ID_EXT,//CAN_MSG_ID_STD
.isRemote = false
};
CAN_ConfigTxBuff(&can_pal2_instance, TX_MAILBOX_CAN2, &Tx_buffCfg);
CAN_Send(&can_pal2_instance, TX_MAILBOX_CAN2, &Tx_msg);
u1_printf("CAN2 send: 20 21 22 23 24 25 26 27\r\n");
"
Hi@fedora
Could you please share the project so that i can test it for you.
I test flexcan0 with pcan and i can see no problem on myside.
But I do find some issues with your flexcan settings.
The sampling point for flexcan0 is 75%, but the sampling points for flexcan1 and flexcan2 are
87.5%, which may cause communication failure.
It is recommended that you first use a PC tool such as PCAN to ensure that each
FLEXCAN instance is working properly.
Thanks, Senlent.
In my project, I hope CAN2 can send the following data that ID is 0x10001, so it's an extended frame;
Expected to the CAN0 can get ID 0x10001 as well , but the ID received by CAN0 is 0x01, why?
can_message_t Tx_msg = {
.cs = 0U,
.id = 0x10001,
.data[0] = 0x20,
.data[1] = 0x21,
.data[2] = 0x22,
.data[3] = 0x23,
.data[4] = 0x24,
.data[5] = 0x25,
.data[6] = 0x26,
.data[7] = 0x27,
.length = 8
};
extended frame format
Hi@fedora
There is no problem with receiving. The error is that you are not sending an extended frame.
place "CAN_ConfigTxBuff()" before "CAN_Send()"
"
{
can_message_t Tx_msg = {
.cs = 0U,
.id = 0x10001,
.data[0] = 0x20,
.data[1] = 0x21,
.data[2] = 0x22,
.data[3] = 0x23,
.data[4] = 0x24,
.data[5] = 0x25,
.data[6] = 0x26,
.data[7] = 0x27,
.length = 8
};
can_buff_config_t Tx_buffCfg = {
.enableFD = false,
.enableBRS = false,
.fdPadding = 0U,
.idType = CAN_MSG_ID_EXT,//CAN_MSG_ID_STD
.isRemote = false
};
CAN_ConfigTxBuff(&can_pal2_instance, TX_MAILBOX_CAN2, &Tx_buffCfg);
CAN_Send(&can_pal2_instance, TX_MAILBOX_CAN2, &Tx_msg);
u1_printf("CAN2 send: 20 21 22 23 24 25 26 27\r\n");
"
Thanks, Senlent!
After testing, your method is correct.
Before calling Can_send, Tx buffer needs to be reinitialized.