yiy 发表于 2022-12-23 16:34

MUG51使用PDMA内存到内存

/*---------------------------------------------------------------------------------------------------------*/
/*                                                                                                         */
/* SPDX-License-Identifier: Apache-2.0                                                                     */
/* Copyright(c) 2022 Nuvoton Technology Corp. All rights reserved.                                       */
/*                                                                                                         */
/*---------------------------------------------------------------------------------------------------------*/

#include "MUG51.h"

/* IMPORTANT !! This define for printf code only. Disable this define to reduce code size. */
//#define print_function

/**
* @brief      I2C0 master demo.
* @param       None
* @return      None
* @Details   please confirm enable LXT and check work stable if use LXT as WKT clock source.
*/

unsigned char xdata RxDatabuffer _at_ 0x100;
unsigned char xdata finalbuffer _at_ 0x263;
unsigned char i;
bit pdmaflag = 0;

void PDMA1_ISR(void) interrupt 21          // Vector @0xAB
{
PDMA_Close(PDMA1);
clr_DMA1TSR_FDONE;
clr_DMA1TSR_HDONE;
pdmaflag = 1;
}

void main (void)
{

#ifdef print_function
/* UART0 initial setting
** include uart.c in Library for UART initial setting
**UART0 define P3.1 TXD multi function setting
**/
Enable_P31_UART0_VCOM_115200_printf();
printf("\n ADC trig by GPIO intial...");
#endif
    for(i=0;i<100;i++)
    {
      RxDatabuffer=i;
    }
/* Define PMDA function as memory to memory, and setting base address */   
    PDMA_Open(PDMA1,XRAM_XRAM,0x100,0x80);
/* Define destination memory address */   
    PDMA_MTM_DestinationAddress(PDMA1,0x200);
/* Define interrupt after full transfer */   
    PDMA_Interrupt_Enable(PDMA1,PDMAFULLINT);
    ENABLE_GLOBAL_INTERRUPT;
    PDMA_Run(PDMA1);

    while(!pdmaflag);
#ifdef print_function
    printf (" \n PDMA Tranfer Finish! 0x%bx", finalbuffer);
#endif
    while(1);
}





zhuotuzi 发表于 2022-12-23 17:22

从一个地址自动搬运到另外一个地址。

huangcunxiake 发表于 2022-12-25 17:36

搬运数据用DMA确实很方便,这个新唐的库函数好用。

星辰大海不退缩 发表于 2022-12-29 13:58

使用后自动搬运地址很方便啊,新唐可以啊

szt1993 发表于 2022-12-30 14:27

数据搬运方便是很好的一个点,省很大得力气

jf101 发表于 2022-12-30 15:09

新唐的这个库函数好用能够快速的进行相关数据搬运处理,DMA内存处理确实很高效
页: [1]
查看完整版本: MUG51使用PDMA内存到内存