• AVR Freaks

Slow PIC32mx DMA routine.

Author
Murton Pike Systems
Senior Member
  • Total Posts : 48
  • Reward points : 0
  • Joined: 2020/09/10 02:13:01
  • Location: 0
  • Status: offline
2020/10/01 15:22:24 (permalink)
4 (1)

Slow PIC32mx DMA routine.

I have found quicker and quicker ways of reading data quickly in from portb on a pic32mx274.
I am now at *ptr++=PORTB; and this gives about 20MHz read speed.
 
I tried running acquisition routine from RAM but there zero improvement.
 
Someone suggested DMA to go even faster.
So  I wrote some DMA code to read from portb into a buffer and best I can get is about 10MHZ read speed.
I find it hard to believe the DMA is slower than just discrete instructions.
Below is my code for di-section.

    
    DCH0CONbits.CHEN = 0; // Turn off this channel

    
        DCH0SSA = KVA_TO_PA(&PORTB); // Move the data from PORTB
    DCH0DSA = KVA_TO_PA(&scopebuffercoherent);// Move the data to scopebuffer

    
    DCH0SSIZ = 4; // Move 4_bytes bytes at a time
    DCH0CSIZ = scopebufferlength*4; // number of bytes to shift
    DCH0DSIZ = scopebufferlength*4; // Move num_bytes bytes of data in total
    DCH0ECON=0; // Clear the DMA configuration settings
    DCH0ECONbits.CHSIRQ = _PMP_VECTOR; // Move data on PMP interrupt
// DCH0ECONbits.CHAIRQ = _PMP_ERROR_VECTOR; // Abort on PMP error
    DCH0ECONbits.SIRQEN = 1; // Enable Start IRQ
    DCH0ECONbits.AIRQEN = 1; // Enable Abort IRQ

    DCH0CONbits.CHPRI = 3; // The priority of this channel is 3 (highest)
    DCH0CONbits.CHEN = 1; // Turn this channel on now

// IPC33bits.DMA0IP = 3; // Set DMA 0 interrupt priority to 3
// IPC33bits.DMA0IS = 1; // Set DMA 0 interrupt sub-priority to 1
// IFS4bits.PMPIF = 0; // Clear the PMP interrupt flag
// IFS4bits.DMA0IF = 0; // Clear the DMA channel 0 interrupt flag
// IEC4bits.DMA0IE = 1; // Enable the DMA 0 interrupt


    DCH0INTbits.CHBCIE = 1; // Enable the Channel Block Transer Complete (CHBC) Interrupt

    DCH0ECONbits.CFORCE = 1; // Force the start of the transfer now

    DMACONSET=0x8000; // Turn the DMA module on
     
     

    
    
 //wait until dma finished

       while (!DCH0INTbits.CHDDIF)
            ;


post edited by nigelwright7558 - 2020/10/01 15:23:38
#1

0 Replies Related Threads

    Jump to:
    © 2020 APG vNext Commercial Version 4.5