2022-06-03 03:59 AM
Hi everyone,
I am working on a FD-CAN project and i am able to send a 64 byte data frame. But I want to send multiple frames of data with different IDs. Any help would be greatly appreciated!
Solved! Go to Solution.
2022-06-06 01:43 AM
Hello,
You're using the filter in Mask Mode and that's normal. Try to use FDCAN_FILTER_RANGE instead of FDCAN_FILTER_MASK.
2022-06-03 04:21 AM
Hello,
What do you mean by "send multiple frames of data with different IDs."?
based on your question, the solution is simply sending successive messages with different IDs
2022-06-03 05:08 AM
Yeah i tried sending successive messages but how can i assign different IDs to every message without changing the TxHeader(as I initialized the ID in TxHeader). Thanks for help.
2022-06-03 06:06 AM
Hello,
Sorry I didn't understand.
You said "assign different IDs to every message" but at the same type you want to keep it by "without changing the TxHeader(as I initialized the ID in TxHeader)"
Do you want to keep the same ID for several messages or set each message with its specific ID?
2022-06-03 06:42 AM
Hi,
Sorry for that. I want to set a specific ID for every message. Again thanks for help.
2022-06-03 07:55 AM
But why you don't want to update TxHeader.Identifier for every message? is there any constraint?
Normally, you have to update each structure member of TxHeader each time there is a change: ID, ID type etc ..
For your case you have to update only TxHeader.Identifier followed by a call of the API that sends FDCAN message such as HAL_FDCAN_AddMessageToTxFifoQ().
2022-06-05 11:33 PM
Hi,
Thanks i tried that. but on receiver side i am receiving the messages from all the IDs into the FDCAN_RX_FIFO0 even after configuring the filter to receive the messages only from a particular ID. In my case i am sending two messages with IDs 0x111 and 0x223 and on receiver side configured the filter to receive the messages only from 0x223 ID but it is also receiving the message from 0x111 ID. my code snippet is shown below:
/* Configure reception filter to Rx FIFO 0 */
sFilterConfig.IdType = FDCAN_STANDARD_ID;
sFilterConfig.FilterIndex = 0;
sFilterConfig.FilterType = FDCAN_FILTER_MASK;
sFilterConfig.FilterConfig = FDCAN_FILTER_TO_RXFIFO0;
sFilterConfig.FilterID1 = 0x223;
sFilterConfig.FilterID2 = 0x7FF;
if (HAL_FDCAN_ConfigFilter(&hfdcan1, &sFilterConfig) != HAL_OK)
{
Error_Handler();
}
/* Configure global filter:
Filter all remote frames with STD and EXT ID
Reject non matching frames with STD ID and EXT ID */
if (HAL_FDCAN_ConfigGlobalFilter(&hfdcan1, FDCAN_REJECT, FDCAN_REJECT, FDCAN_FILTER_REMOTE, FDCAN_FILTER_REMOTE) != HAL_OK)
{
Error_Handler();
}
/* Activate Rx FIFO 0 new message notification */
if (HAL_FDCAN_ActivateNotification(&hfdcan1, FDCAN_IT_RX_FIFO0_NEW_MESSAGE, 0) != HAL_OK)
{
Error_Handler();
}
void HAL_FDCAN_RxFifo0Callback(FDCAN_HandleTypeDef *hfdcan, uint32_t RxFifo0ITs)
{
if((RxFifo0ITs & FDCAN_IT_RX_FIFO0_NEW_MESSAGE) != 0)
{
/* Retrieve Rx messages from RX FIFO0 */
if (HAL_FDCAN_GetRxMessage(hfdcan, FDCAN_RX_FIFO0, &RxHeader, RxData) != HAL_OK)
{
Error_Handler();
}
2022-06-06 01:43 AM
Hello,
You're using the filter in Mask Mode and that's normal. Try to use FDCAN_FILTER_RANGE instead of FDCAN_FILTER_MASK.
2022-06-06 04:45 AM
Hi,
Thanks for the help. Now i am able to filter out the messages according to IDs.
2022-06-07 01:48 AM
Hello,
Thank you for the feedback.
Could you please mark my answer that resolved your issue by selecting "Select as best". This will help other users find that answer faster.