#S32K388 Enhanced RX FIFO + eDMA: Continuous Circular Buffer Reception Without CPU Interrupts

cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 

#S32K388 Enhanced RX FIFO + eDMA: Continuous Circular Buffer Reception Without CPU Interrupts

43 Views
zhangyu5454
Contributor III

Hi NXP Support,

I am using an S32K388 with the FlexCAN Enhanced RX FIFO and RTD. I would like to implement a continuous DMA-based CAN reception without any CPU interrupt.

My requirements are:

  • MCU: S32K388

  • CAN: Classical CAN, CAN FD disabled

  • CAN payload: 8 bytes

  • FlexCAN Enhanced RX FIFO enabled

  • DMA reception enabled

  • I need to receive CAN messages with any CAN ID, without filtering.

  • I want DMA to automatically transfer every received CAN frame into a RAM software ring buffer.

  • I do not want a FlexCAN RX interrupt.

  • I also do not want a DMA major-loop-complete interrupt.

  • DMA should continue running automatically without the CPU having to call FlexCAN_Ip_RxFifo() again.

  • Ideally, each received FIFO element should trigger a DMA transfer immediately, so I do not want to wait for a large FIFO watermark.

I checked the RTD source code. In FlexCAN_StartRxMessageEnhancedFifoData(), I found that the driver configures DMA approximately as follows:

Source address              = Enhanced RX FIFO output
Source transfer size        = 4 bytes
Source offset               = 4 bytes
Destination transfer size   = 4 bytes
Destination offset          = 4 bytes
Minor loop size             = 80 bytes
Major loop count            = num_enhanced_watermark
EnMajorInt                  = TRUE
DisAutoHwRequest            = TRUE

I understand that the current RTD implementation performs a finite DMA transfer and then stops, requiring FlexCAN_Ip_RxFifo() to be called again.

My question is:

Is it possible on S32K388 to configure the eDMA TCD so that the FlexCAN Enhanced RX FIFO DMA request continuously transfers received FIFO elements into a circular RAM buffer, without any CPU interrupt or software re-arming?

In particular, can Destination Modulo and/or another eDMA TCD feature be used to implement this continuous ring buffer?

If this is possible, could you please provide an example configuration or point me to an NXP example/reference implementation?

I am willing to modify the RTD FlexCAN driver or configure the eDMA TCD directly if necessary.

Thanks!

Tags (1)
0 Kudos
Reply
1 Reply

11 Views
Julián_AragónM
NXP TechSupport
NXP TechSupport

Hello @zhangyu5454,

The driver is written in a way that requires FlexCAN_Ip_RxFifo() to be called in order to re-arm reception inside the FLEXCAN_EVENT_DMA_COMPLETE event.

It should be possible to have a continuous transfer from DMA to buffer; however, you will need to modify the RTDs or create your own driver. Unfortunately, this is out of our support scope, and if done, verification and functionality should be tested by you.

You would have to set TCDn_CSR[D_REQ] = 0 (DisAutoHwRequest = FALSE) & TCDn_CSR[INTMAJOR] in order to keep the channel armed and disable interrupts, as well as configure your circular data queue. You can refer to S32K3's DMA Training Presentation, under S32K3 Product Page and 'Secure Files'.

Best regards,
Julián

0 Kudos
Reply
%3CLINGO-SUB%20id%3D%22lingo-sub-2411682%22%20slang%3D%22en-US%22%20mode%3D%22CREATE%22%3E%23S32K388%20Enhanced%20RX%20FIFO%20%2B%20eDMA%3A%20Continuous%20Circular%20Buffer%20Reception%20Without%20CPU%20Interrupts%3C%2FLINGO-SUB%3E%3CLINGO-BODY%20id%3D%22lingo-body-2411682%22%20slang%3D%22en-US%22%20mode%3D%22CREATE%22%3E%3CP%3EHi%20NXP%20Support%2C%3C%2FP%3E%3CP%3EI%20am%20using%20an%20%3CSTRONG%3ES32K388%3C%2FSTRONG%3E%20with%20the%20%3CSTRONG%3EFlexCAN%20Enhanced%20RX%20FIFO%3C%2FSTRONG%3E%20and%20RTD.%20I%20would%20like%20to%20implement%20a%20%3CSTRONG%3Econtinuous%20DMA-based%20CAN%20reception%20without%20any%20CPU%20interrupt%3C%2FSTRONG%3E.%3C%2FP%3E%3CP%3EMy%20requirements%20are%3A%3C%2FP%3E%3CUL%3E%3CLI%3E%3CP%3EMCU%3A%20%3CSTRONG%3ES32K388%3C%2FSTRONG%3E%3C%2FP%3E%3C%2FLI%3E%3CLI%3E%3CP%3ECAN%3A%20%3CSTRONG%3EClassical%20CAN%3C%2FSTRONG%3E%2C%20CAN%20FD%20disabled%3C%2FP%3E%3C%2FLI%3E%3CLI%3E%3CP%3ECAN%20payload%3A%20%3CSTRONG%3E8%20bytes%3C%2FSTRONG%3E%3C%2FP%3E%3C%2FLI%3E%3CLI%3E%3CP%3EFlexCAN%20Enhanced%20RX%20FIFO%20enabled%3C%2FP%3E%3C%2FLI%3E%3CLI%3E%3CP%3EDMA%20reception%20enabled%3C%2FP%3E%3C%2FLI%3E%3CLI%3E%3CP%3EI%20need%20to%20receive%20CAN%20messages%20with%20%3CSTRONG%3Eany%20CAN%20ID%3C%2FSTRONG%3E%2C%20without%20filtering.%3C%2FP%3E%3C%2FLI%3E%3CLI%3E%3CP%3EI%20want%20DMA%20to%20automatically%20transfer%20every%20received%20CAN%20frame%20into%20a%20%3CSTRONG%3ERAM%20software%20ring%20buffer%3C%2FSTRONG%3E.%3C%2FP%3E%3C%2FLI%3E%3CLI%3E%3CP%3EI%20do%20not%20want%20a%20FlexCAN%20RX%20interrupt.%3C%2FP%3E%3C%2FLI%3E%3CLI%3E%3CP%3EI%20also%20do%20not%20want%20a%20DMA%20major-loop-complete%20interrupt.%3C%2FP%3E%3C%2FLI%3E%3CLI%3E%3CP%3EDMA%20should%20continue%20running%20automatically%20without%20the%20CPU%20having%20to%20call%20FlexCAN_Ip_RxFifo()%20again.%3C%2FP%3E%3C%2FLI%3E%3CLI%3E%3CP%3EIdeally%2C%20each%20received%20FIFO%20element%20should%20trigger%20a%20DMA%20transfer%20immediately%2C%20so%20I%20do%20not%20want%20to%20wait%20for%20a%20large%20FIFO%20watermark.%3C%2FP%3E%3C%2FLI%3E%3C%2FUL%3E%3CP%3EI%20checked%20the%20RTD%20source%20code.%20In%20FlexCAN_StartRxMessageEnhancedFifoData()%2C%20I%20found%20that%20the%20driver%20configures%20DMA%20approximately%20as%20follows%3A%3C%2FP%3E%3CPRE%3ESource%20address%20%20%20%20%20%20%20%20%20%20%20%20%20%20%3D%20Enhanced%20RX%20FIFO%20output%0ASource%20transfer%20size%20%20%20%20%20%20%20%20%3D%204%20bytes%0ASource%20offset%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%3D%204%20bytes%0ADestination%20transfer%20size%20%20%20%3D%204%20bytes%0ADestination%20offset%20%20%20%20%20%20%20%20%20%20%3D%204%20bytes%0AMinor%20loop%20size%20%20%20%20%20%20%20%20%20%20%20%20%20%3D%2080%20bytes%0AMajor%20loop%20count%20%20%20%20%20%20%20%20%20%20%20%20%3D%20num_enhanced_watermark%0AEnMajorInt%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%3D%20TRUE%0ADisAutoHwRequest%20%20%20%20%20%20%20%20%20%20%20%20%3D%20TRUE%3C%2FPRE%3E%3CP%3EI%20understand%20that%20the%20current%20RTD%20implementation%20performs%20a%20finite%20DMA%20transfer%20and%20then%20stops%2C%20requiring%20FlexCAN_Ip_RxFifo()%20to%20be%20called%20again.%3C%2FP%3E%3CP%3EMy%20question%20is%3A%3C%2FP%3E%3CP%3E%3CSTRONG%3EIs%20it%20possible%20on%20S32K388%20to%20configure%20the%20eDMA%20TCD%20so%20that%20the%20FlexCAN%20Enhanced%20RX%20FIFO%20DMA%20request%20continuously%20transfers%20received%20FIFO%20elements%20into%20a%20circular%20RAM%20buffer%2C%20without%20any%20CPU%20interrupt%20or%20software%20re-arming%3F%3C%2FSTRONG%3E%3C%2FP%3E%3CP%3EIn%20particular%2C%20can%20%3CSTRONG%3EDestination%20Modulo%3C%2FSTRONG%3E%20and%2For%20another%20eDMA%20TCD%20feature%20be%20used%20to%20implement%20this%20continuous%20ring%20buffer%3F%3C%2FP%3E%3CP%3EIf%20this%20is%20possible%2C%20could%20you%20please%20provide%20an%20example%20configuration%20or%20point%20me%20to%20an%20NXP%20example%2Freference%20implementation%3F%3C%2FP%3E%3CP%3EI%20am%20willing%20to%20modify%20the%20RTD%20FlexCAN%20driver%20or%20configure%20the%20eDMA%20TCD%20directly%20if%20necessary.%3C%2FP%3E%3CP%3EThanks!%3C%2FP%3E%3C%2FLINGO-BODY%3E%3CLINGO-SUB%20id%3D%22lingo-sub-2412174%22%20slang%3D%22en-US%22%20mode%3D%22CREATE%22%20translate%3D%22no%22%3ERe%3A%20%23S32K388%20Enhanced%20RX%20FIFO%20%2B%20eDMA%3A%20Continuous%20Circular%20Buffer%20Reception%20Without%20CPU%20Interrupts%3C%2FLINGO-SUB%3E%3CLINGO-BODY%20id%3D%22lingo-body-2412174%22%20slang%3D%22en-US%22%20mode%3D%22CREATE%22%3E%3CP%3EHello%26nbsp%3B%3CA%20href%3D%22https%3A%2F%2Fcommunity.nxp.com%2Ft5%2Fuser%2Fviewprofilepage%2Fuser-id%2F253638%22%20target%3D%22_blank%22%3E%40zhangyu5454%3C%2FA%3E%2C%3C%2FP%3E%0A%3CP%3EThe%20driver%20is%20written%20in%20a%20way%20that%20requires%20FlexCAN_Ip_RxFifo()%20to%20be%20called%20in%20order%20to%20re-arm%20reception%20inside%20the%20%3CSPAN%3EFLEXCAN_EVENT_DMA_COMPLETE%20event%3C%2FSPAN%3E.%3C%2FP%3E%0A%3CP%3EIt%20should%20be%20possible%20to%20have%20a%20continuous%20transfer%20from%20DMA%20to%20buffer%3B%20however%2C%20you%20will%20need%20to%20modify%20the%20RTDs%20or%20create%20your%20own%20driver.%26nbsp%3BUnfortunately%2C%20this%20is%20out%20of%20our%20support%20scope%2C%20and%20if%20done%2C%20verification%20and%20functionality%20should%20be%20tested%20by%20you.%3C%2FP%3E%0A%3CP%3EYou%20would%20have%20to%20set%20TCDn_CSR%5BD_REQ%5D%20%3D%200%20(DisAutoHwRequest%20%3D%20FALSE)%20%26amp%3B%20TCDn_CSR%5BINTMAJOR%5D%20in%20order%20to%20keep%20the%20channel%20armed%20and%20disable%20interrupts%2C%20as%20well%20as%20configure%20your%20circular%20data%20queue.%20You%20can%20refer%20to%20S32K3's%20DMA%20Training%20Presentation%2C%20under%26nbsp%3B%3CA%20href%3D%22https%3A%2F%2Fwww.nxp.com%2Fproducts%2FS32K3%22%20target%3D%22_self%22%20rel%3D%22nofollow%20noopener%20noreferrer%22%3ES32K3%20Product%20Page%3C%2FA%3E%26nbsp%3Band%20'Secure%20Files'.%3C%2FP%3E%0A%3CP%3EBest%20regards%2C%3CBR%20%2F%3EJuli%C3%A1n%3C%2FP%3E%3C%2FLINGO-BODY%3E