MCF52223EVB DMA data transfer

取消
显示结果 
显示  仅  | 搜索替代 
您的意思是: 

MCF52223EVB DMA data transfer

1,282 次查看
ad777
Contributor I
Hello,

Does anyone have any tips on how to go about using DMA controller for data transfer?

Thanks.
标签 (1)
0 项奖励
回复
1 回复

395 次查看
mjbcswitzerland
Specialist V
Hi

DMA can be used for memory-memory transfer or together with DMA timers and UARTs. The exact use varies depending on which method is reuired.

Here's a quick example of doing memory-memory transfer as a starter:

Code:
        DMA_SR_BCR3 = ((unsigned long)(Size));                           // the number of byte transfers to be made (SR_BCRn)        if ((unsigned long)ptrFrom < START_OF_SRAM) {                                DMA_SAR3 = (BACKDOOR_FLASH + (unsigned long)ptrFrom);        // if from FLASH, set to backdoor        }        else {            DMA_SAR3  = (unsigned long)ptrFrom;                          // address of first byte to be transfered  (SARn)        }        DMA_DAR3  = (unsigned long)ptrTo;                                // address of first destination byte       (DARn)        DMA_DCR3  = (DCR_BWC_16K | DCR_SINC | DCR_DINC | DCR_SSIZE_BYTE | DCR_DSIZE_BYTE | DCR_START); // set up DMA operation (DCRn) and start DMA transfer        while (!(DMA_SR_BCR3 & DSR_DONE)) { SIM_DMA_3 };                 // wait until the transfer has terminated        DMA_SR_BCR3 = DSR_DONE;                                          // clear all status bits ready for future transfer

Note that:
- DMA can not access FLASH directly but must use a backdoor address.
- DMA controller doesn't always have rights to access memory and peripherals:

GPACR0 = SUP_USER_FULL_ACCESS;  for example allows peripheral access.

The following is needed to allow FLASH access (as in the comment, this is also required for the USB DMA controller to be able to access FLASH)
    PACR1 = 0x04;                                                        // enable DMA to access FLASH (also by USB DMA controller)
    GPACR1 = 0x04;
 
There may be various other details depending on exact use.

You could also look at the uTasker project since this includes DMA support for memory and UARTs and supports your chip.

Regards

Mark

www.uTasker.com


0 项奖励
回复