LockedSimple DMA - PMP transfer

Author
DarioG
Scheisse Menschen
  • Total Posts : 52256
  • Reward points : 0
  • Joined: 2006/02/25 08:58:22
  • Location: hi there
  • Status: online
2012/07/14 02:09:22 (permalink)
0

Simple DMA - PMP transfer

Am just starting on this, but, based upon this thread
http://www.microchip.com/forums/m648726.aspx
and others too, "how" can we use DMA to transfer a bunch of bytes (say 256) from PMPIN to LATD (for example) ?
Is it possible at all? From what I read in there.. it looks like either the source buffer or the dest. buffer has to be large "count" times (256 in my case)...
 
thanks!

Dario Greggio
--
Wouldn't it be wonderful, if you lost one son for every promise you don't keep?
#1

13 Replies Related Threads

    DarioG
    Scheisse Menschen
    • Total Posts : 52256
    • Reward points : 0
    • Joined: 2006/02/25 08:58:22
    • Location: hi there
    • Status: online
    Re:Simple DMA - PMP transfer 2012/07/14 02:32:46 (permalink)
    0
    As suspected, this

            DmaChnSetTxfer(3, &PMDIN, &LATD, 1, 1, 256);

    is not working or rather it only copies 1 byte a time (kind of useless Smile )
     

    Dario Greggio
    --
    Wouldn't it be wonderful, if you lost one son for every promise you don't keep?
    #2
    DarioG
    Scheisse Menschen
    • Total Posts : 52256
    • Reward points : 0
    • Joined: 2006/02/25 08:58:22
    • Location: hi there
    • Status: online
    Re:Simple DMA - PMP transfer 2012/07/14 03:56:07 (permalink)
    0
    Hmm, the trick is in LCC as someone suggested Smile

    Dario Greggio
    --
    Wouldn't it be wonderful, if you lost one son for every promise you don't keep?
    #3
    DarioG
    Scheisse Menschen
    • Total Posts : 52256
    • Reward points : 0
    • Joined: 2006/02/25 08:58:22
    • Location: hi there
    • Status: online
    Re:Simple DMA - PMP transfer 2012/07/14 05:07:08 (permalink)
    0
    Yep... but then it has some buffer - I suppose a dual-port RAM accessed by the LCD. I mean, it still can't move from a register to another more than one "word" at once, even if it's timer-triggered.
    And you still need an IRQ anyway.
     
    Learning is nice!

    Dario Greggio
    --
    Wouldn't it be wonderful, if you lost one son for every promise you don't keep?
    #4
    DarioG
    Scheisse Menschen
    • Total Posts : 52256
    • Reward points : 0
    • Joined: 2006/02/25 08:58:22
    • Location: hi there
    • Status: online
    Re:Simple DMA - PMP transfer 2012/07/16 11:46:38 (permalink)
    0
    Looks like nobody had anything to say about this Smile
    Well, I went deep into details of DMA and learned some things about it.
    I can't actually understand some things:
    • at what frequency will DMA work? theoretically it should tun at PBclock, then I saw some "cycle time" in the graphs, but checking with a Scope I can't exactly figure it out. I.e. RAM to LATD goes circa 50-70nS per write (80MHz Clock and PBClock)
    • When the above is applied to PMP, things become slower (understandable) but the factor is, again, curious...
    • I tried using 2 DMA channels and 2 buffers - one for copying from PMP to RAM and another for going from RAM to LATD. Makes some sense, it works (using interrupts from Timer 2 as in LCC) but... the reads from PMP seem to "hang" (or wait) every in a while: each access seem to take 70-75nSec, but it will do only 8 per "frame" instead of 16 as I ask. If I ask 32, I can see some 12 plus a "remainder" of 4 in the next frame... Strange.
    • And then. what happens if 2 DMA channels try to access the same RAM? I did my tests using separate buffers but...
    • When I set it up like this  
      DmaChnSetTxfer(1, (void*)&GraphicsFrame[0],(void*)&LATD,DISP_HOR_RESOLUTION*2,2,16);
      I can see that a "sub-chunk" is transferred at each Timer2 expire, and I get a DMA IRQ when the full transfer is done. But is there a way to have one full transfer for each Timer2 trigger?
    Currently, I seem to be able to read 1280 bytes (640 words) using a software loop into the "hidden" buffer, and at the same time using DMA to send the "current" buffer to LATD i.e. to VGA. Including HSync and VSync as per standard. I overclocked to 96MHz Smile and the software loop takes 28uS (i.e. 7 less than max)
    I switched to 16bits PMP so I need a 100pin device... !

    Dario Greggio
    --
    Wouldn't it be wonderful, if you lost one son for every promise you don't keep?
    #5
    DarioG
    Scheisse Menschen
    • Total Posts : 52256
    • Reward points : 0
    • Joined: 2006/02/25 08:58:22
    • Location: hi there
    • Status: online
    Re:Simple DMA - PMP transfer 2012/07/16 13:38:28 (permalink)

    Dario Greggio
    --
    Wouldn't it be wonderful, if you lost one son for every promise you don't keep?
    #6
    Mike017
    Super Member
    • Total Posts : 2698
    • Reward points : 0
    • Joined: 2007/08/25 08:11:31
    • Location: Lincoln, RI, USA
    • Status: offline
    Re:Simple DMA - PMP transfer 2012/07/16 13:39:49 (permalink)
    0
    Dario,
     
    at what frequency will DMA work? theoretically it should tun at PBclock,
    Yes, from assorted sources, theoretically the CPU speed.
     
    And then. what happens if 2 DMA channels try to access the same RAM? I did my tests using separate buffers but...
    From DiJasio's book regarding chaining 2 DMA channels (they must be contiguous) for SPI ....
     
     
    // chain DMA0 to completion of DMA1 transfer
    DMAChnSetControl(0, DMA_CTL_CHAIN_EN | DMA_CTL_CHAIN_DIR);
    (I havn't checked the book errata in this section)
     
    Also, I came across a code example a while back for large DMA transfers. I'll post back if I can find it. Hopefully, it's for PIC32.
     
    EDIT: On this page, filter on "General Purpose" then choose PIC32_DMA_Codeexample (10/19/2011). Then the large PMP transfer source file is pmp_txfer >> source>>pmp_txfer_large.
     
    Good Luck,
    Mike 
     
    post edited by Mike017 - 2012/07/16 13:49:52
    #7
    DarioG
    Scheisse Menschen
    • Total Posts : 52256
    • Reward points : 0
    • Joined: 2006/02/25 08:58:22
    • Location: hi there
    • Status: online
    Re:Simple DMA - PMP transfer 2012/07/16 13:57:58 (permalink)
    0
    Thank you Mike! it's indeed a complicated "beast" so I'm taking a look at it all.
    But I meant "at the same time", i.e. I prepare and start 2 transfers that involve the same area: then, it seems to work.... will it? (I mean, store from PMP to buffer and read from buffer to LATD...)

    Dario Greggio
    --
    Wouldn't it be wonderful, if you lost one son for every promise you don't keep?
    #8
    DarioG
    Scheisse Menschen
    • Total Posts : 52256
    • Reward points : 0
    • Joined: 2006/02/25 08:58:22
    • Location: hi there
    • Status: online
    Re:Simple DMA - PMP transfer 2012/07/16 14:17:29 (permalink)
    0
    Took a look at that (and other) examples. Indeed I've been through them - similar ones - in these days. I still wonder about the actual speed of the transfer (vs. what I saw in the Scope) and a couple of other questions as above... !
    I contacted a FAE too, so let's wait Smile

    Dario Greggio
    --
    Wouldn't it be wonderful, if you lost one son for every promise you don't keep?
    #9
    DarioG
    Scheisse Menschen
    • Total Posts : 52256
    • Reward points : 0
    • Joined: 2006/02/25 08:58:22
    • Location: hi there
    • Status: online
    Re:Simple DMA - PMP transfer 2012/07/16 14:37:59 (permalink)
    0
    Aargh, I can see that even on a 100 pin part, using 16bits PMP there is NO FULL 16bits Port available... crazy!
    I can see RB0..7 and RA0..7 ... maybe, but this severaly impacts my timing... ! Who knows if an inverted DMA mode can do? will see!

    Dario Greggio
    --
    Wouldn't it be wonderful, if you lost one son for every promise you don't keep?
    #10
    Mike017
    Super Member
    • Total Posts : 2698
    • Reward points : 0
    • Joined: 2007/08/25 08:11:31
    • Location: Lincoln, RI, USA
    • Status: offline
    Re:Simple DMA - PMP transfer 2012/07/16 20:53:57 (permalink)
    0
    Dario,
    I prepare and start 2 transfers that involve the same area: then, it seems to work.... will it? (I mean, store from PMP to buffer and read from buffer to LATD...)
    The PMP read could be an issue. Check Errata #24 and post #3 here. Caveat Emptor... That being said, some of Microchip's graphics tools are built around using PMP + DMA +SRAM for the smaller displays so there must be workaround for that errata.
     
    Good Luck,
    Mike
     
    #11
    DarioG
    Scheisse Menschen
    • Total Posts : 52256
    • Reward points : 0
    • Joined: 2006/02/25 08:58:22
    • Location: hi there
    • Status: online
    Re:Simple DMA - PMP transfer 2012/07/17 00:31:18 (permalink)
    0
    I had gone through that thread, yeah,
    not that I've worked with the chips it makes more sense to me...
     
    I am not actually triggering like that, though I can see that it could be nice: I resolved using the Timer to trigger and it was good enough. As for "missing reads" from PMP, today a FAE replied to me that only ONE DMA channel is active at a time, so this (actually, obvious) would explain the above.
    What is a bit "worse" is that the accesses by DMA are a bit "slow" (he says 5-7 cycles).. of course it's slow only for this application Smile
    Anyway, it would look like I can get 640x480x16...
     
    thank you Smile

    Dario Greggio
    --
    Wouldn't it be wonderful, if you lost one son for every promise you don't keep?
    #12
    adamfolts
    Super Member
    • Total Posts : 212
    • Reward points : 0
    • Joined: 2010/10/19 08:32:20
    • Location: Prescott
    • Status: offline
    Re:Simple DMA - PMP transfer 2012/07/17 07:19:19 (permalink)
    0
    When the LCC method reads from SRAM, it shares the read lines with the LCD. This eliminates the need for another 16 IO lines on the PIC and it eliminates needing 2 DMA transfers (1 to the PIC and then one to the LCD). I don't know your application, but one workaround to get another 16 IO lines would be to use the PMP Address Register and then enable the PMP address lines, you may be using those lines already though.
    #13
    DarioG
    Scheisse Menschen
    • Total Posts : 52256
    • Reward points : 0
    • Joined: 2006/02/25 08:58:22
    • Location: hi there
    • Status: online
    Re:Simple DMA - PMP transfer 2012/07/17 15:00:21 (permalink)
    0
    Yeah Adam, I kind of realized it has to go like that.
    In my case I need the 16 I/O lines to go to 3 DACs ... so am not sure what I will do.

    Dario Greggio
    --
    Wouldn't it be wonderful, if you lost one son for every promise you don't keep?
    #14
    Jump to:
    © 2017 APG vNext Commercial Version 4.5