S32K1xx SDK - FlexCAN RX individual mask

cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 

S32K1xx SDK - FlexCAN RX individual mask

Jump to solution
3,058 Views
MS499
Contributor II

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

Labels (1)
0 Kudos
Reply
1 Solution
3,024 Views
MS499
Contributor II

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

View solution in original post

0 Kudos
Reply
4 Replies
3,025 Views
MS499
Contributor II

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

0 Kudos
Reply
3,018 Views
PetrS
NXP TechSupport
NXP TechSupport

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

0 Kudos
Reply
3,011 Views
MS499
Contributor II

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

0 Kudos
Reply
3,047 Views
PetrS
NXP TechSupport
NXP TechSupport

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 

0 Kudos
Reply