• AVR Freaks

PIC32 DMA problem

Author
ibaggett
New Member
  • Total Posts : 23
  • Reward points : 0
  • Joined: 2010/03/18 07:28:48
  • Location: 0
  • Status: offline
2010/03/18 08:00:31 (permalink)
0

PIC32 DMA problem

Hi,

I'm trying to work with the DMA in the PIC32.  I have 3 dev boards (PIC32 Starter, USB Starter, and Ethernet Starter).  Using the example program "uart_echo.c" in "All_PIC32_Code_Examples\dma\uart_echo", I find a serious problem with the DMA operation in the dev boards that use the 360 and 460 variants of the PIC32.  The 795 variant does not exhibit the problem.

Here is what happens.  When I program the DMA channel destination size for 257 bytes (DCH1DSIZ = 257), somehow it only loads the value 1.  And it operates as if it had been set to 1, that is, it transfers only 1 byte and then stops.  Now, if I program it with 256, it reads back as 0, but operates as 256.  That is, it transfers 256 bytes and then stops.  If I program it with 512, it reads back as 0, and transfers 256.  Freaky enough for you?

The above behavior was observed on both the 360 and 460 variants.  The same tests run on a 795 produced correct behavior.

I've looked at all the errata but can't find a mention of this anywhere.  There are DMA errata, but not for this issue.

Anyone got more info or suggestions?  The obvious one is to use only a 795 part, but I'm kind of hoping someone else has seen this before and knows a solution or workaround.

Thanks,
Ivan

#1

9 Replies Related Threads

    olaoni
    Starting Member
    • Total Posts : 45
    • Reward points : 0
    • Joined: 2010/02/18 05:25:02
    • Location: 0
    • Status: offline
    RE: PIC32 DMA problem 2010/03/18 08:51:59 (permalink)
    0
    Hi Ivan,

    Try using a smaller value that 256. I will advice try sending 250 bytes. It that works then look into bank selection.

    Regards

    Ola
    #2
    ibaggett
    New Member
    • Total Posts : 23
    • Reward points : 0
    • Joined: 2010/03/18 07:28:48
    • Location: 0
    • Status: offline
    RE: PIC32 DMA problem 2010/03/18 09:18:01 (permalink)
    0
    Hi Olaoni,

    I tried your suggestion.  That worked.  However, the memory spaces in PIC32 aren't banked, so bank selection should have nothing to do with it.  According to the datasheet, the DMA source and destination size registers have 16 bits that are implemented.  That should give up to 65535 byte transfer capability.  Of course, there is a 'note' that "Depending on the device variant, not all bits are available. Refer to the specific device data sheet for details".  But the 3XX-4XX device datasheet doesn't say anything about implementing only 8 bits in the 3XX-4XX variants.

    I guess I'm stuck with using only 256 bytes or fewer for DMA transfers, unless I step up to the 795 variant.  It would be nice if Microchip would document this somewhere.  It would also be nice if they actually tested their example program on a 3XX-4XX.  Then they would know not to program 257 bytes destination size in their example (which doesn't work as it should on 3XX-4XX parts).

    If any Microchip support folks want to comment on this, please do.  An official word would be nice.

    Olaoni, thanks for your help.

    Ivan

    #3
    Nigle
    Super Member
    • Total Posts : 298
    • Reward points : 0
    • Joined: 2008/10/14 04:09:08
    • Location: London
    • Status: offline
    RE: PIC32 DMA problem 2010/03/18 09:32:52 (permalink)
    0
    ORIGINAL: ibaggett
    But the 3XX-4XX device datasheet doesn't say anything about implementing only 8 bits in the 3XX-4XX variants.

    Yes it does. In table 10-1 the entry in the Transfer Length column says <=256B and the descriptions of the source and destination size registers have bits 8-31 greyed out.

    It would help if there was a big warning on the first page of that section, though!
    #4
    ibaggett
    New Member
    • Total Posts : 23
    • Reward points : 0
    • Joined: 2010/03/18 07:28:48
    • Location: 0
    • Status: offline
    RE: PIC32 DMA problem 2010/03/18 09:45:45 (permalink)
    0
    Hi Nigle,

    What datasheet are you quoting from?  The only one I can find (DS61143F) is the one that has a 1-page description of the DMA controller, and says

    "Refer to the “PIC32MX
    Family Reference Manual” Section 31.
    “Direct Memory Access (DMA) Controller”
    (DS61117) for a detailed description of
    this peripheral."

    Which I did, and that manual doesn't have Table 10.1 in it.

    Thanks,

    Ivan

    #5
    Nigle
    Super Member
    • Total Posts : 298
    • Reward points : 0
    • Joined: 2008/10/14 04:09:08
    • Location: London
    • Status: offline
    RE: PIC32 DMA problem 2010/03/18 09:53:05 (permalink)
    0
    I have the previous version, it has far more information in it. You can find it here.

    Looks like Microchip dropped the ball ( again ).

    #6
    ibaggett
    New Member
    • Total Posts : 23
    • Reward points : 0
    • Joined: 2010/03/18 07:28:48
    • Location: 0
    • Status: offline
    RE: PIC32 DMA problem 2010/03/18 10:15:52 (permalink)
    0
    Nigle,

    And there it is, in Table 10.1, just like you said.  Thanks for the tip and the link.

    I suggest that anyone reading this should burn it into their brain that PIC32 DMA has this limitation for some variants.

    Ivan

    #7
    pirev
    Starting Member
    • Total Posts : 35
    • Reward points : 0
    • Joined: 2004/12/17 04:25:56
    • Status: offline
    RE: PIC32 DMA problem 2010/03/29 10:38:59 (permalink)
    0
    You can use function DmaGetMaxTxferSize() . It return correct size.
    #8
    rainad
    Super Member
    • Total Posts : 1402
    • Reward points : 0
    • Joined: 2009/05/01 13:39:25
    • Location: 0
    • Status: offline
    RE: PIC32 DMA problem 2010/04/13 15:19:00 (permalink)
    0
    The "PIC32_Code_Examples\dma\uart_echo", example is wrong.

    Instead of
    DmaChnSetTxfer(chn, (void*)&U2RXREG, dmaBuff, 1, sizeof(dmaBuff), 1);

    it should be

    DmaChnSetTxfer(chn, (void*)&U2RXREG, dmaBuff, 1, 256, 1);


    For PIC32MX3xx-4xx the maximum transfer size returned by DmaGetMaxTxferSize() is 256 bytes.

    For PIC32MX5xx-6xx-7xx the maximum transfer size is 64 Kbytes.
    #9
    ibaggett
    New Member
    • Total Posts : 23
    • Reward points : 0
    • Joined: 2010/03/18 07:28:48
    • Location: 0
    • Status: offline
    RE: PIC32 DMA problem 2010/04/13 15:36:15 (permalink)
    0
    Thanks for that info, rainad.  My DMA application is working fine now, after much grief.  FYI, here is the other thread on DMA issues I was having, which may help others in their quest to use DMA:

    http://www.microchip.com/forums/tm.aspx?m=487885

    At this point, DMA proves to be a useful means to move data from peripheral to memory while NVM flash is self-programming, with the modifications I made to the PIC32 library functions (see my other thread).

    Ivan

    #10
    Jump to:
    © 2020 APG vNext Commercial Version 4.5