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:
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!
Hi,
If you want to receive all CAN ID you only need to set the filter mask registers to 0.
Best regards,
Felipe
Hi, Felipe.
Could you tell me which register is filter mask register? Is there any api for this?
The example implements filters by using FLEXCAN_SetRxMbGlobalMask function.
Regards,
Felipe
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)
{
}