Dear Support team,
Is there any example for CAN DMA using SDK's? I didn't find any CAN based on DMA...I am having some trouble in making it to work.
Hi,
As far as I know there is no FlexCAN SDK example using the DMA.
However the usage should be similar as for the interrupt mode. In the Component inspector you configure the module for RXFIFO and DMA mode.
In the main function you need call DMA_init just before FlexCAN_init, as below
/* Initialize eDMA module & channels */
EDMA_DRV_Init(&dmaController1_State, &dmaController1_InitConfig0, edmaChnStateArray, edmaChnConfigArray, EDMA_CONFIGURED_CHANNELS_COUNT);
/* Initialize FlexCAN driver */
FLEXCAN_DRV_Init(INST_CANCOM1, &canCom1_State, &canCom1_InitConfig0);
Nothing more is needed.
Finaly you need to configure RXFIFO using FLEXCAN_DRV_ConfigRxFifo and call FLEXCAN_DRV_RxFifo to start receiving CAN frame using the Rx FIFO. This function must be called again after you receive data to allow another data to be received.
BR, Petr
Hi,
I config the CAN FIFO as follows, the sending messages is ok, but always can't receive messages as expected.
main()
{
flexcan_msgbuff_t rx_msgbuf;
flexcan_data_info_t tx_info;
uint8_t data[8];
EDMA_DRV_Init(&dmaController1_State, &dmaController1_InitConfig0, edmaChnStateArray, edmaChnConfigArray, EDMA_CONFIGURED_CHANNELS_COUNT);
FLEXCAN_DRV_Init(INST_CANCOM1, &canCom1_State, &canCom1_InitConfig0);
FLEXCAN_DRV_ConfigTxMb(INST_CANCOM1, 15, &tx_info, 0x100);
for(;;)
{
/* Rx FIFO */
FLEXCAN_DRV_RxFifo(INST_CANCOM1, &rx_msgbuf);
/* Send a message */
tx_info.msg_id_type = 0;
tx_info.data_length = 8;
FLEXCAN_DRV_Send(INST_CANCOM1, 15, &tx_info, 0x100, &data);
}
}
Hello,
First what version of SDK did you use and what processor ?
Second provide the configuration of the can driver ?
And 3 you forget to config the Fifo filters by calling FLEXCAN_DRV_ConfigRxFifo before call the reception FLEXCAN_DRV_RxFifo;
And 4 wait the transfer to finish before rearm again the transfer.
/* Config Fifo Filters */
flexcan_id_table_t flTable[10];
for(i=0;i<10;i++)
{
flTable[i].id=i;
flTable[i].isExtendedFrame=false;
flTable[i].isRemoteFrame=false;
}
FLEXCAN_DRV_ConfigRxFifo(INST_CANCOM1,FLEXCAN_RX_FIFO_ID_FORMAT_A,&flTable[0]);
/* End Config Fifo Filters */
for(;;)
{
/* Rx FIFO */
/* Wait to finish received fifo data, allways the Fifo Data will be pulled from MB0 */
while(FLEXCAN_DRV_GetTransferStatus(INST_CANCOM1, 0) == STATUS_BUSY);
FLEXCAN_DRV_RxFifo(INST_CANCOM1, &rx_msgbuf);
/* Send a message */
tx_info.msg_id_type = 0;
tx_info.data_length = 8;
FLEXCAN_DRV_Send(INST_CANCOM1, 15, &tx_info, 0x100, &data);
/* Wait to finish send data */
while(FLEXCAN_DRV_GetTransferStatus(INST_CANCOM1, 15) == STATUS_BUSY);
}
BR,
Alexandru Nan
Hello,
I want a Rx example SDK FlexCAN and RXFIFO using DMA.
Could you help us?..
Thanks.
You can find an example here https://community.nxp.com/docs/DOC-343091