KW36 flexcan how to receive all CAN id

取消
显示结果 
显示  仅  | 搜索替代 
您的意思是: 

KW36 flexcan how to receive all CAN id

1,600 次查看
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!

标签 (1)
标记 (1)
0 项奖励
4 回复数

1,427 次查看
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 项奖励

1,427 次查看
jictannu
Contributor III

Hi, Felipe.

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

0 项奖励

1,427 次查看
FelipeGarcia
NXP Employee
NXP Employee

The example implements filters by using FLEXCAN_SetRxMbGlobalMask function.

 

Regards,

Felipe

0 项奖励

1,427 次查看
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 项奖励