flexbus and DMA

cancel
Showing results for 
Search instead for 
Did you mean: 

flexbus and DMA

1,173 Views
AlexGiov
Contributor II

Hi

I've a question about flexbus on kinetis (I use K60).

I need to trasfer a large file from on-chip ram to an external memory connected on the flexbus. I need to do this with low CPU intervention.

 

is it possible wiht flexbus?

 

In other word can I copy a on-chip memory zone (from address A to addressB) out through flexbus?

 

In other word, again, Is it possible to use flexbus with DMA on Kinets?

 

thanks a lot for help.

AlexGiov

2 Replies

59 Views
ee
Contributor II

Here's a snippet from my K70 flexbus DMA code using CW10.2.  I previously setup my flexbus for 32-bit transfers starting at address 0x60000000.

 

#define FLEXBUS_START_ADDRESS    0x60000000
#define NWORDS        1000
uint32    dmaBuf[NWORDS];

    SIM_SCGC7 |= SIM_SCGC7_DMA_MASK;
    DMA_CSR_REG(DMA_BASE_PTR,1) = 0;
    
        // major loop count (current = beginning)
    DMA_CITER_ELINKNO_REG(DMA_BASE_PTR,1) =
    DMA_BITER_ELINKNO_REG(DMA_BASE_PTR,1) = 1;
        // minor loop count (in bytes), word sizes
    DMA_NBYTES_MLNO_REG(DMA_BASE_PTR,1) = NWORDS << 2;
    DMA_ATTR_REG(DMA_BASE_PTR,1) =
              DMA_ATTR_SMOD(0)| DMA_ATTR_SSIZE(2)
            | DMA_ATTR_DMOD(0)| DMA_ATTR_DSIZE(2) ;
    
        // source addr, inc, end adj
    DMA_SADDR_REG(DMA_BASE_PTR,1) = (uint32)&dmaBuf;
    DMA_SOFF_REG(DMA_BASE_PTR,1) = sizeof(uint32);
    DMA_SLAST_REG(DMA_BASE_PTR,1) = -(NWORDS << 2);
        // dest addr, inc, end adj
    DMA_DADDR_REG(DMA_BASE_PTR,1) = FLEXBUS_START_ADDRESS;
    DMA_DOFF_REG(DMA_BASE_PTR,1) = 0;
    DMA_DLAST_SGA_REG(DMA_BASE_PTR,1) = 0;

 

DMA is now ready to loop through my dmaBuf, transfering all 1000 32-bit words out to a single flexbus location. I call this statement every 1ms (in my main systick event loop) to trigger it:

    DMA_CSR_REG(DMA_BASE_PTR,1) |= DMA_CSR_START_MASK;


In the future I will add completion interrupts and error checking and such, but for now this minimal code seems to be doing the job quite reliably.  DMA is a beautiful thing.

Steve Kaiser

59 Views
mjbcswitzerland
Specialist V

Hi

 

Yes, it is possible to perform a DMA transfer from internal memory to FlexBus memory.

 

Regards

 

Mark

 

0 Kudos