KW36 flexcan how to receive all CAN id

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

KW36 flexcan how to receive all CAN id

1,584 Views
jictannu
Contributor III

I am using frdmkw36_driver_examples_flexcan_interrupt_transfer and I want to receive all can id. I set rxIdentifier to 0x00, input 'B', send CAN message. The KW36 can receive my message, but then it receive  what it just send endlessly: 

pastedImage_2.png

The txIdentifier is 0x321. And I add this code:

flexcan_rx_fifo_config_t rxFifoConfig;
uint32_t rxFifoFilter[] = {
FLEXCAN_RX_FIFO_STD_FILTER_TYPE_A(txIdentifier, 0, 0),
FLEXCAN_RX_FIFO_STD_FILTER_TYPE_A(txIdentifier, 1, 0),
};

....

/* Setup Rx FIFO. */
rxFifoConfig.idFilterTable = rxFifoFilter;
rxFifoConfig.idFilterType = kFLEXCAN_RxFifoFilterTypeA;
rxFifoConfig.idFilterNum = sizeof(rxFifoFilter) / sizeof(rxFifoFilter[0]);
rxFifoConfig.priority = kFLEXCAN_RxFifoPrioHigh;

...

FLEXCAN_SetRxFifoConfig(EXAMPLE_CAN, &rxFifoConfig, true);

Then it works, but when I send more than 6 messages, it receive what it just send again. I really need your help!

Labels (1)
Tags (1)
0 Kudos
4 Replies

1,411 Views
FelipeGarcia
NXP Employee
NXP Employee

Hi,

 

If you want to receive all CAN ID you only need to set the filter mask registers to 0.

 

Best regards,

Felipe

0 Kudos

1,411 Views
jictannu
Contributor III

Hi, Felipe.

Could you tell me which register is filter mask register? Is there any api for this?

0 Kudos

1,411 Views
FelipeGarcia
NXP Employee
NXP Employee

The example implements filters by using FLEXCAN_SetRxMbGlobalMask function.

 

Regards,

Felipe

0 Kudos

1,411 Views
jictannu
Contributor III

Thanks for your response! I have solved this problem with those code:

/* Set Freeze, Halt bits. */
EXAMPLE_CAN->MCR |= CAN_MCR_FRZ_MASK;
EXAMPLE_CAN->MCR |= CAN_MCR_HALT_MASK;

/* Wait until the FlexCAN Module enter freeze mode. */
while (!(EXAMPLE_CAN->MCR & CAN_MCR_FRZACK_MASK))
{
}
EXAMPLE_CAN->MCR |= CAN_MCR_SRXDIS(1);
/* Clear Freeze, Halt bits. */
EXAMPLE_CAN->MCR &= ~CAN_MCR_HALT_MASK;
EXAMPLE_CAN->MCR &= ~CAN_MCR_FRZ_MASK;

/* Wait until the FlexCAN Module exit freeze mode. */
while (EXAMPLE_CAN->MCR & CAN_MCR_FRZACK_MASK)
{
}

0 Kudos