[SOLVED] LPC4337: Couldn't get DMA started.

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

[SOLVED] LPC4337: Couldn't get DMA started.

780 Views
lpcware
NXP Employee
NXP Employee

Content originally posted in LPCWare by Pacman on Mon Nov 04 01:35:27 MST 2013
I had difficulties getting the DMA started and got stuck.

 

It seemed I tried everything I could possibly think of, but after sleeping on the problem, I woke up and was reminded:
"The AHB Master 0 can only access memory."

 

So I got up and changed the code that I posted here, now I changed my question to an answer for those who also get stuck.

 

Attached is a file called DMA-Transfer.c...
I've made it quite minimalistic and put everything in one file for an easy overview.
-So it should be possible to compile and test it on most setups.

 

The following is basically what I'm doing:

 

  [*]Set all GPIO port 2 pins to output
  [*]Output a dummy value 0xc3, so I can see if it changes.
  [*]Turn on BASE_M4_CLK if it's not on already (it would be)
  [*]Disable DMA interrupts in NVIC (I don't use any)
  [*]Connect DMA branch clock to BASE_M4_CLK (should be on after reset anyway)
  [*]Stop/disable DMA Channel 0
  [*]Enable DMA
  [*]Clear pending bits and error bits.
  [*]Set up a source address, destination address and transfer size
  [*]Set up transfer type (Destination transfer must use AHB Master 0, not AHB Master 1)
  [*]Start the DMA
  [*]See that the 8 LEDs connected to GPIO port 2 changed.
  [*]See that the 2 leds toggle in the main-loop, to confirm that the main loop is running.

Original Attachment has been moved to: DMA-Transfer.c.zip

Labels (1)
0 Kudos
4 Replies

516 Views
lpcware
NXP Employee
NXP Employee
Content originally posted in LPCWare by Pacman on Wed Nov 13 22:14:52 MST 2013
I was expecting that you were reading a camera, perhaps one of the small CMOS OV7670 or similar ?

Have in mind that I might not be doing things right. :)
-You may be able to find a better / faster way, if you do, please let me know, because I'm in the video-picture business as well, just sending the picture the other way.
0 Kudos

516 Views
lpcware
NXP Employee
NXP Employee
Content originally posted in LPCWare by dwjperry on Wed Nov 13 14:43:18 MST 2013
I hope that's not the case, I'm pulling data from a camera and need as much speed as I can get!
0 Kudos

516 Views
lpcware
NXP Employee
NXP Employee
Content originally posted in LPCWare by Pacman on Wed Nov 13 07:00:03 MST 2013
I'm happy it could help you. Yes, the memory-to-memory detail in the documentation is probably a copy-and-paste error from the LPC17xx or perhaps LPC18xx.

Unfortunately, it seems that the DMA might be slower, when it's accessing the GPIO ports. Hopefully I'm wrong, but if you've seen my other recent post about the DMA, I'm having problems getting beyond 12MHz (24000000 changes per second).
0 Kudos

516 Views
lpcware
NXP Employee
NXP Employee
Content originally posted in LPCWare by dwjperry on Tue Nov 12 21:01:33 MST 2013
Thanks for this, I had a lot of trouble going the other direction (trying to load GPIO into RAM via the DMA), and this helped me figure it out.

It's needlessly confusing, the manual says GPIO can be accessed as a memory to memory transfer. However, if you use GPDMA_Setup(..) with TransferType set to GPDMA_TRANSFERTYPE_M2M_CONTROLLER_DMA it uses AHB Master 0, which can't seem to access GPIO (i.e. you have to treat it as a peripheral sourced transfer after all, not memory sourced).

I had to manually tweak the library to set GPDMA_DMACCxControl_SrcTransUseAHBMaster1 (i.e. use AHB Master 1) to get it working.

NXP: May I suggest your manual needs a more clarification on handling GPIO sourced DMA (p381)? It also appears the firmware GPDMA library needs tweaking to explicitly support this.


0 Kudos