DMA STREAM (JSAPI_DMASTREAM)

DMA (Direct Memory Access) is a hardware component that transfers data between a peripheral unit or a memory block and another peripheral or memory block without CPU intervention. Without DMA, CPU instructions must be used to copy the data, using up CPU cycles. In ST’s implementation, a device may have up to two DMA units, each one with eight “streams”. Each DMA stream is a programmable channel for data transfer.

Not all peripherals can be used with DMA. You must refer to the device manuals to find out which DMA stream can be used with a particular peripheral.

DMA-Stream JumpStart API is only available in the STM32F4xx and STM32F7xx JumpStart API libraries. It creates a simplified interface to the DMA stream hardware. Typically, you would set up DMA transfer between a peripheral and a memory block using the MakeStream function, then invoke the peripheral function that uses the DMA feature.

To demonstrate the DMA features, you need to attach additional hardware to the ST-Nucleo. Therefore, no example is provided here.

STM32F4xx/STM32F7xx Only:

Object

extern JSAPI_DMA_STREAM dma1s0, dma1s1, dma1s2, dma1s3, dma1s4, dma1s5, dma1s6, dma1s7, dma2s0, dma2s1, dma2s2, dma2s3, dma2s4, dma2s5, dma2s6, dma2s7;

Enum

enum DMA_XFER_MODE {

    PERIPH_TO_MEM,  // Peripheral to memory transfer

    MEM_TO_PERIPH,  // Memory to peripheral transfer

    MEM_TO_MEM      // Memory to memory transfer

};

Make a DMA stream

int MakeStream(

    unsigned channel,

    void *periph_addr,

    unsigned periph_size,

    void *mem_addr,

    unsigned mem_size,

    bool auto_incr,

    unsigned total_items,

    enum DMA_XFER_MODE mode,

    bool *status

);

Disable the MDA unit

void Disable(void);

 

How to Use

To use the JumpStart DMA Stream API:

1.       For the peripheral that you want to use DMA with, find out from the device manual which DMA unit and which stream can be used with the peripheral.

2.       Initialize the associated JSAPI_DAMSTREAM object (e.g. dma1d0) with a call to its MakeStream method.

3.       Invoke the DMA action with the peripheral object.