Hi
I want to receive 20 messages(which has different IDs and DATA) from the upper computer, but i use CAN2 which just has 16 MBs. Using FLEXCAN_DRV_ConfigRxMb(can_interface, mailbox, &dataInfo, msg_id) and
FLEXCAN_DRV_Receive(can_interface, mailbox,recvBuff) to initialize CAN2. so it just can receive 16 messages. How to configure the function to receive 20 messages.
Thank you very much
Hi,
I have similar issue, I am trying to send different IDs over the same MB:
The MB is RX_MB_KVASER=1 and the IDs are CAN_ID_SET_PWM=0x01 and CAN_ID_READ_PWM=0x02
FLEXCAN_DRV_ConfigRxMb(INST_FLEXCAN_CONFIG_1,RX_MB_KVASER,&CAN_TX_MB_Config,CAN_ID_SET_PWM);
FLEXCAN_DRV_ConfigRxMb(INST_FLEXCAN_CONFIG_1,RX_MB_KVASER,&CAN_TX_MB_Config,CAN_ID_READ_PWM);
FLEXCAN_DRV_SetRxIndividualMask(INST_FLEXCAN_CONFIG_1,FLEXCAN_MSG_ID_STD, RX_MB_KVASER,0);
I also set the Individual mask to zero, also call to FLEXCAN_DRV_Receive( INST_FLEXCAN_CONFIG_1,RX_MB_KVASER,&recvMsg); for the starting of the interrupts.
But it didnt work
Hello,
If you cannot use another instance which supports more message buffers, you can configure ID masks for each message buffer. These masks could match on a range of IDs, so you could receive multiple IDs in the same message buffer.
In order to configure an individual mask for each message buffer, please refer to the FLEXCAN_DRV_SetRxIndividualMask(uint8_t instance, flexcan_msgbuff_id_type_t id_type, uint8_t mb_idx, uint32_t mask) function. The second parameter chooses between standard and extended ID, the third parameter specifies for which message buffer this filter applies, while the last parameter specifies a binary mask for the incoming ID.
This mask is applied to the ID with which the message buffer was configured using FLEXCAN_DRV_ConfigRxMb() and this masked ID will be check with the incoming ID. A value of 0b means that the respective bit from the ID is "don't care", while 1b means that the respective bit will be checked.
Please let me know if you have any other questions.
Best regards,
Ana
Dear Ana
Thank you for your reply. I configured functions like you said.
flexcan_data_info_t dataInfo =
{
.data_length = 1U,
.msg_id_type = FLEXCAN_MSG_ID_EXT,
.enable_brs = true,
.fd_enable = true,
.fd_padding = 0U
};
FLEXCAN_DRV_SetRxIndividualMask(INTERFACE_CAN2,FLEXCAN_MSG_ID_EXT,0,0x00000000);
FLEXCAN_DRV_ConfigRxMb(INTERFACE_CAN2, 0, &dataInfo, 0x18FF0917);
I use CAN2 ,extended ID,0Mail_box,and binary mask is 0x00000000. 0x18FF0917 is one of the ID which I want to receive. My ISR functin is as the follow
void Flexcan2_ISR(uint8_t instance,
flexcan_event_type_t eventType,
flexcan_state_t *flexcanState)
{
(void)flexcanState;
(void)instance;
switch(eventType)
{
case FLEXCAN_EVENT_RX_COMPLETE:
FLEXCAN_DRV_Receive(INTERFACE_CAN2, 1, &can0_recvBuff);
CAN2_RX_ST = CAN_RX_FINISH;
break;
case FLEXCAN_EVENT_TX_COMPLETE:
break;
default:
break;
}
}
However ,in the modle of debug ,I can not receive any messages.
I look forward to your reply.
Best regards,
YUAN
Hello,
In order to receive a CAN message you must call the FLEXCAN_DRV_Receive which enables the Rx interrupts. The event handler is called from the internal FlexCAN interrupt handler. So, if you haven't previously called FLEXCAN_DRV_Receive, the event handler will not be called either. The event handler will be called when the receive was completed and the data was already moved from the peripheral buffer to the user buffer.
Regards,
Ana
Hi Ana
I'm glad to tell you that it can receive a CAN message according to what you tell me. As follows:
FLEXCAN_DRV_ConfigRxMb(can_interface, mailbox, &dataInfo, msg_id);
FLEXCAN_DRV_Receive(can_interface, mailbox,recvBuff);
FLEXCAN_DRV_SetRxIndividualMask(can_interface,FLEXCAN_MSG_ID_EXT,0,0x00000u);
(can_interface =INTERFACE_CAN2; mailbox =0; FLEXCAN_MSG_ID_EXT =1 ,msg_id =0x18FF0917)
But I meet a new problem that the message'ID I received is just 0x18FF0917 . In fact,I want receive multiple messages which has different ID.
I have two problems, No1:The binary mask in function of FLEXCAN_DRV_SetRxIndividualMask() is right?? If it's wrong ,what it should be .
No2:The configuration as I do whether can receive multiple messages or not , if not, whta if should be.
I look forward to your reply.
Regards,
YUAN
Hello Yuan,
First of all, please change the order of the following functions:
FLEXCAN_DRV_ConfigRxMb(can_interface, mailbox, &dataInfo, msg_id);
FLEXCAN_DRV_SetRxIndividualMask(can_interface,FLEXCAN_MSG_ID_EXT,0,0x00000u);
FLEXCAN_DRV_Receive(can_interface, mailbox,recvBuff);
Moreover, you need to call FLEXCAN_DRV_Receive for each frame you're expecting, because after each successful receive, the Rx interrupts are disabled. You could call FLEXCAN_DRV_Receive in a while loop and get notified by the successful receive by the event handler.
Regards,
Ana
Hey, I have same query I tried with same order but still receiving only one frame if id which is defined as msg_id. Not receiving other than that.
FLEXCAN_DRV_ConfigRxMb(can_interface, mailbox, &dataInfo, msg_id);
FLEXCAN_DRV_SetRxIndividualMask(can_interface,FLEXCAN_MSG_ID_EXT,0,0x00000u);
FLEXCAN_DRV_Receive(can_interface, mailbox,recvBuff);
Other than that,
I tried same using can_pal,
can_buff_config_t buffCfg = {
.enableFD = false,
.enableBRS = false,
.fdPadding = 0U,
.idType =CAN_MSG_ID_EXT,
.isRemote = false
};
CAN_ConfigRxBuff(&can_pal1_instance, RX_MAILBOX, &buffCfg, RX_MSG_ID);
CAN_SetRxFilter(&can_pal1_instance,CAN_MSG_ID_EXT,RX_MAILBOX,0x00000u);
CAN_Receive(&can_pal1_instance, RX_MAILBOX, &recv_msg);
By using can_pal, I am able to receive more than one message but not all. There is some data loss using can_pal.
By using flex_can, not able to to set no filer mask.
Please help me here. I need to receive all can messages with no filter.
I would request you to help me with basic configuration of CAN ON s32k144.
Hi Ana,
In CAN_MASTER_Example, I did not find the function definition of "FLEXCAN_DRV_Receive".
Could you tell me it was defined in which file?
Best regards,
Ethan
hello Ana,
I read this question and all of the replies. That is useful to me.
But for last reply "You could call FLEXCAN_DRV_Receive in a while loop and get notified by the successful receive by the event handler.", I still can not understand. Can you explain for detail for me?
I have same requirement with Yuan--also want to receive multiple messages with one MB.
Now, in my ISR, I will call FLEXCAN_DRV_ConfigRxMb to configure another ID message, then call FLEXCAN_DRV_Receive to start reception. But I found I will missing some messages.
Thank you for your before answer. Looking forward to your reply~~
Hi Ana
Thank you for your help, I have solved my problem.
Thanks again.
Regards,
Yuan