KW36 flexcan how to receive all CAN id

キャンセル
次の結果を表示 
表示  限定  | 次の代わりに検索 
もしかして: 

KW36 flexcan how to receive all CAN id

2,885件の閲覧回数
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 返答(返信)

2,712件の閲覧回数
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 件の賞賛
返信

2,712件の閲覧回数
jictannu
Contributor III

Hi, Felipe.

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

0 件の賞賛
返信

2,712件の閲覧回数
FelipeGarcia
NXP Employee
NXP Employee

The example implements filters by using FLEXCAN_SetRxMbGlobalMask function.

 

Regards,

Felipe

0 件の賞賛
返信

2,712件の閲覧回数
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 件の賞賛
返信