CAN using DMA and RxFIFO

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

CAN using DMA and RxFIFO

3,859件の閲覧回数
rameshkumardura
Contributor I

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.

ラベル(1)
タグ(1)
5 返答(返信)

2,839件の閲覧回数
PetrS
NXP TechSupport
NXP TechSupport

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.

pastedImage_1.png

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

2,839件の閲覧回数
gary_lu
Contributor I

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);

}

}

0 件の賞賛
返信

2,839件の閲覧回数
alexandrunan
NXP Employee
NXP Employee

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

0 件の賞賛
返信

2,839件の閲覧回数
aaaaaaap
Contributor I

Hello,

I want a Rx example SDK FlexCAN and RXFIFO using DMA.

Could you help us?.. 

Thanks.

0 件の賞賛
返信

2,839件の閲覧回数
alexandrunan
NXP Employee
NXP Employee

You can find an example here https://community.nxp.com/docs/DOC-343091