Hi,
I am currently working on a CAN Application which is supposed to receive numerous CAN FD Messages with a Data Length of 64 Bytes. In my current configuration I am only able to use 6 Message Boxes and RX FIFO is disabled. Therefore, I configured my own Message Boxes as described in the reference manual via the following commands:
FLEXCAN_DRV_Init()
FLEXCAN_DRV_ConfigRxMb()
FLEXCAN_DRV_Receive()
Up to now I am able to receive CAN Messages with fixed IDs. Caused by some memory restrictions I cannot configure all necessary IDs. Hence, I tried to apply an individual mask, which only checks the last 4 bit of a received CAN ID. I used the following commands:
FLEXCAN_DRV_Init()
FLEXCAN_DRV_SetRxMaskType()
FLEXCAN_DRV_SetRxIndividualMask()
FLEXCAN_DRV_ConfigRxMb()
FLEXCAN_DRV_Receive()
So far this has not yielded a positive result. I am not able to receive a CAN Message that way. After the failed attempt with the individual mask I tried to configure a global mask and set all global mask bits to 0 ("don´t care"). This way I should have received any CAN Message regardless of the CAN ID. But sadly that didn´t work either.
I hope you can help me with my before mentioned issue and I am looking forward to hear from you. If you need any further information or specific configurations that I have made so far please let me now.
Best Regards,
MS499
Solved! Go to Solution.
Hi,
thank you for your answer.
I am using the S32K118, the S32DS in Version 3.4 and the SDK Version 3.4.1.
A S32K144 development board is also available and can be used for evaluation if necessary.
The functions are used as follows:
/* where as the flexcan_data_info_s contains information about the CAN message (enable_brs, fd_padding, data_length, is_remote, msg_id_type,
fd_enable). the can_message_ps pointer on a struct contains the data, ID etc. of the CAN Message */
lexcan_user_config_t flexcanInitConfig0 = {
.flexcanMode = FLEXCAN_NORMAL_MODE,
.fd_enable = true,
.payload = FLEXCAN_PAYLOAD_SIZE_64,
.max_num_mb = 6UL,
.num_id_filters = FLEXCAN_RX_FIFO_ID_FILTERS_8,
.is_rx_fifo_needed = false,
.transfer_type = FLEXCAN_RXFIFO_USING_INTERRUPTS,
.rxFifoDMAChannel = 0U,
.pe_clock = FLEXCAN_CLK_SOURCE_PERIPH,
.bitrate = {
.propSeg = 7UL,
.phaseSeg1 = 7UL,
.phaseSeg2 = 6UL,
.preDivider = 3UL,
.rJumpwidth = 0UL
},
.bitrate_cbt = {
.propSeg = 9UL,
.phaseSeg1 = 6UL,
.phaseSeg2 = 6UL,
.preDivider = 1UL,
.rJumpwidth = 0UL
}
};
FLEXCAN_DRV_Init(INST_FLEXCAN_CONFIG_1, &flexcanState0, &flexcanInitConfig0)
FLEXCAN_DRV_SetRxMaskType(INST_FLEXCAN_CONFIG_1, FLEXCAN_RX_MASK_INDIVIDUAL);
FLEXCAN_DRV_SetRxIndividualMask(INST_FLEXCAN_CONFIG_1, flexcan_data_info_s.msg_id_type, can_message_ps->message_buffer_id_U8
, can_message_ps->rx_mask_U32);
FLEXCAN_DRV_ConfigRxMb(INST_FLEXCAN_CONFIG_1, can_message_ps->message_buffer_id_U8, &flexcan_data_info_s, can_message_ps->message_buffer_s.message_id_U32);
FLEXCAN_DRV_Receive(INST_FLEXCAN_CONFIG_1, can_message_ps->message_buffer_id_U8, &can_message_ps->message_buffer_s);
The RX Mask used is 0b1111, since I want to filter the received CAN IDs based on the last 4bit received. The IDs I am trying to receive are the following: 0x100, 0x110, 0x700, 0x160, 0x170.
I am looking forward to hearing from you and if you need any further information please let me know.
Best Regards,
MS499
Hi,
thank you for your answer.
I am using the S32K118, the S32DS in Version 3.4 and the SDK Version 3.4.1.
A S32K144 development board is also available and can be used for evaluation if necessary.
The functions are used as follows:
/* where as the flexcan_data_info_s contains information about the CAN message (enable_brs, fd_padding, data_length, is_remote, msg_id_type,
fd_enable). the can_message_ps pointer on a struct contains the data, ID etc. of the CAN Message */
lexcan_user_config_t flexcanInitConfig0 = {
.flexcanMode = FLEXCAN_NORMAL_MODE,
.fd_enable = true,
.payload = FLEXCAN_PAYLOAD_SIZE_64,
.max_num_mb = 6UL,
.num_id_filters = FLEXCAN_RX_FIFO_ID_FILTERS_8,
.is_rx_fifo_needed = false,
.transfer_type = FLEXCAN_RXFIFO_USING_INTERRUPTS,
.rxFifoDMAChannel = 0U,
.pe_clock = FLEXCAN_CLK_SOURCE_PERIPH,
.bitrate = {
.propSeg = 7UL,
.phaseSeg1 = 7UL,
.phaseSeg2 = 6UL,
.preDivider = 3UL,
.rJumpwidth = 0UL
},
.bitrate_cbt = {
.propSeg = 9UL,
.phaseSeg1 = 6UL,
.phaseSeg2 = 6UL,
.preDivider = 1UL,
.rJumpwidth = 0UL
}
};
FLEXCAN_DRV_Init(INST_FLEXCAN_CONFIG_1, &flexcanState0, &flexcanInitConfig0)
FLEXCAN_DRV_SetRxMaskType(INST_FLEXCAN_CONFIG_1, FLEXCAN_RX_MASK_INDIVIDUAL);
FLEXCAN_DRV_SetRxIndividualMask(INST_FLEXCAN_CONFIG_1, flexcan_data_info_s.msg_id_type, can_message_ps->message_buffer_id_U8
, can_message_ps->rx_mask_U32);
FLEXCAN_DRV_ConfigRxMb(INST_FLEXCAN_CONFIG_1, can_message_ps->message_buffer_id_U8, &flexcan_data_info_s, can_message_ps->message_buffer_s.message_id_U32);
FLEXCAN_DRV_Receive(INST_FLEXCAN_CONFIG_1, can_message_ps->message_buffer_id_U8, &can_message_ps->message_buffer_s);
The RX Mask used is 0b1111, since I want to filter the received CAN IDs based on the last 4bit received. The IDs I am trying to receive are the following: 0x100, 0x110, 0x700, 0x160, 0x170.
I am looking forward to hearing from you and if you need any further information please let me know.
Best Regards,
MS499
Hi,
thank you for a code, but still it is not clear, what is going to be used in last 3 functions.
Do you use std ID? What ID is written into MB? The mask is 0x4?
Or share values written into MB and RXIMR taken from debugger.
BR, Petr
Hi,
thank you for your answer.
I have resolved the issue. It was caused by a false call of the initialize function that I implemented which contained calls to the before mentioned functions. The library works as expected know.
Best Regards,
MS499
Hi,
could you please specify the S32DS and SDK version you are using? Also the device.
Seems you are using correct functions, however it is not clear how. Could you give more info on this?
What IDs are used and should be received (std/ext), how did you set mask, etc.
BR, Petr