Forums

SSP DMA problem in ARM lpc2388

Started by faiz1303 3 years ago7 replieslatest reply 3 years ago130 views

Hi,

Hi,

I am working on a project, in which I want to copy a data from SD card (on SSP0) to  a USB flash drive, I want to reduce the time span required to copy data from SD card to USB drive,so  I decided to use a DMA. No such provision to access the DMA, to copy data from SD card to USB directly , I must first need to copy few bytes in memory buffer, then transfer that bytes from memory buffer to USB drive repeatedly to copy 8GB. I also explore the sample DMA example in code bundle LPC23xx-24xx Sample Software. Can you suggest a simpler way to accomplish this DMA transfer. 

Can you please tell me, is it possible to copy  only  few sectors from the sd card using DMA, as I am only passing the ssp0 address 0xE0068008 and USB ram as dest 0x7FD00000.

Please helpDMA-SD.png

[ - ]
Reply by mr_banditJanuary 17, 2019

Generally, DMA needs either a memory buffer or a device register. It looks like the ssp0 device register is either not getting set correctly (the picture shows 8008, not E0068008) or it is not properly responding to the DMA request.

The first thing i would suggest you do, in order to understand the DMA, is copy from one memory buffer to another (if possible), or from a simpler peripheral (eg a serial port).

Also - keeping in mind the last time I did DMA on an ARM was 20 years ago... See if the DMA is "sexed", meaning one end is meant for memory, and one for a device. I had this problem - each end is ONLY for a device or memory, and you cannot switch the two (will not work). Once setup, you can specify the direction of the neutron flow.

But - if you get the right end on the right thing, and the device register works like the DMA expects, you should be able to do this. As far as the USB flash write, you may have issues with timing.

Implement each "leg" separately - keep your tests as simple as possible. For the flash write, first do it the "hard" way - explicit calls, no DMA, so you understand the sequence/timing/voodoo first. There will be gotchas...

Have fun!

[ - ]
Reply by faiz1303January 22, 2019

Thanks mr_bandit,

I didn't get any thing working, I thought that the problem is in SSP initialization. Please tell me, what if I initialize the SD CARD  read and write using SPI, and SSP to access the DMA data transfer from SD CARD to USB pen Drive. Is it possible for the above case, And one more thing , can I copy a particular sectors with DMA, instead of copying for start to end. 

Please suggest

[ - ]
Reply by mr_banditJanuary 22, 2019

Get a simple DMA working for some device (eg UART) to memory. You have a lot of moving parts, and you need to solve the pieces before you can solve the big one. You currently do not understand the voodoo of either the SDCard or the DMA. You must first master both. You need to write a series of little test programs to grok the pieces.

Can you use the SPI to talk to the SDCard? Specifically, can you write code to do it "by hand", meaning using explicit code? This will teach you howto actually interface (read/write) with the SDCard.

To answer the particular sectors question, you first need to do it by hand. It may be that you need to first send commands to the SDCard to setup a particular sector rd/wr. (I bet you must do that.) If so, you may first need to setup the DMA but not start it, do the commands by hand (explicitly), then turn the DMA on to do the data transfer.

See if the DMA hardware is "sexed" - one end can only be hardware, the other end only memory. This bit me - took a week to figure out && get my little test program to work.

Keep trying! You will learn a lot!

[ - ]
Reply by KocsonyaJanuary 25, 2019

The 23xx series chips use the ARM DMA macroblock, which is notoriously hard to set up properly. In addition, you need to set up the SSP correctly, which, by the way, is an other ARM macroblock with its own set of problems.

So, before doing DMA I would write a simple interrupt driven SSP and check whether that works. If it's all nice and you are certain that there's nothing wrong with your SD -> SSP -> memory -> USB -> flash chain, then you can re-code the SSP driver to use DMA.

Also, without you showing us how you set up the DMA, we can't really tell you what might be wrong with its configuration.

Furthermore, most LPC23xx chips that have USB also have an MMC interface, which makes talking to an SD card just soooo much easier, not to mention faster.

[ - ]
Reply by faiz1303January 25, 2019

Thanks Kocsonya,

Sorry for posting a insufficient information, I  first try to do as you have suggested, I am having a problem, when I use a SD card with SSP0, but its working fine with SPI. Can I use a SPI to read/write sd card and SSP-DMA to access data from sd card to usb drive. Please suggest

thanks & regards 

[ - ]
Reply by KocsonyaJanuary 25, 2019

I can only repeat my suggestion: try to make your SD work with the SSP using interrupts. Until that works, forget the DMA. 

You will need to understand the SSP in any case. Configuring the SSP is not very hard, but certainly more complex than the SPI. But you will need to configure it whether you use DMA or not. The DMA just adds more complexity. In general, debug one module at a time; debugging two interdependent low-level drivers simultaneously is no small feast. 

In my experience, the one step at a time approach gets you there much faster.

[ - ]
Reply by faiz1303January 25, 2019

Thanks Kocsonya,

First I concentrate on SDcard with SSP, and then only I will move forward with DMA.