Workflow

  1. 1.
    Define the variables needed, in order to perform a data transfer:
    uint32_t i;
    uint32_t cfg;
    dma_transfer_descriptor_t desc;
    
  2. 2.
    Prepare the data buffer to be transferred:
    for (i = 0; i < DMA_BUF_SIZE; i++) {
        g_dma_buf[0][i] = i;
        g_dma_buf[1][i] = 0;
    }
    
  3. 3.
    Initialize the DMAC module:
    dmac_init(DMAC);
    
  4. 4.
    Set the priority to round-robin:
    dmac_set_priority_mode(DMAC, DMAC_PRIORITY_ROUND_ROBIN);
    
  5. 5.
    Enable the DMAC module:
    dmac_enable(DMAC);
    
  6. 6.
    Configure the channel for:
    • Enable stop on done

    • Enable AHB protection

    • Set the FIFO so that largest defined length AHB burst is performed
      cfg = DMAC_CFG_SOD_ENABLE |        
              DMAC_CFG_AHB_PROT(1) |     
              DMAC_CFG_FIFOCFG_ALAP_CFG; 
      dmac_channel_set_configuration(DMAC, DMA_CH, cfg);