[DemoCode下载] MUG51使用PDMA内存到内存

[复制链接]
590|5
 楼主| yiy 发表于 2022-12-23 16:34 | 显示全部楼层 |阅读模式
  1. /*---------------------------------------------------------------------------------------------------------*/
  2. /*                                                                                                         */
  3. /* SPDX-License-Identifier: Apache-2.0                                                                     */
  4. /* Copyright(c) 2022 Nuvoton Technology Corp. All rights reserved.                                         */
  5. /*                                                                                                         */
  6. /*---------------------------------------------------------------------------------------------------------*/

  7. #include "MUG51.h"

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

  10. /**
  11. * [url=home.php?mod=space&uid=247401]@brief[/url]        I2C0 master demo.
  12. * @param       None
  13. * [url=home.php?mod=space&uid=266161]@return[/url]      None
  14. * [url=home.php?mod=space&uid=1543424]@Details[/url]     please confirm enable LXT and check work stable if use LXT as WKT clock source.
  15. */

  16. unsigned char xdata RxDatabuffer[100] _at_ 0x100;
  17. unsigned char xdata finalbuffer _at_ 0x263;
  18. unsigned char i;
  19. bit pdmaflag = 0;

  20. void PDMA1_ISR(void) interrupt 21          // Vector [url=home.php?mod=space&uid=72445]@[/url]  0xAB
  21. {
  22.   PDMA_Close(PDMA1);
  23.   clr_DMA1TSR_FDONE;
  24.   clr_DMA1TSR_HDONE;
  25.   pdmaflag = 1;
  26. }

  27. void main (void)
  28. {

  29. #ifdef print_function
  30.   /* UART0 initial setting
  31.   ** include uart.c in Library for UART initial setting
  32.   **UART0 define P3.1 TXD multi function setting
  33.   **/
  34.   Enable_P31_UART0_VCOM_115200_printf();
  35.   printf("\n ADC trig by GPIO intial...");
  36. #endif
  37.     for(i=0;i<100;i++)
  38.     {
  39.       RxDatabuffer[i]=i;
  40.     }
  41. /* Define PMDA function as memory to memory, and setting base address */   
  42.     PDMA_Open(PDMA1,XRAM_XRAM,0x100,0x80);
  43. /* Define destination memory address */   
  44.     PDMA_MTM_DestinationAddress(PDMA1,0x200);
  45. /* Define interrupt after full transfer */   
  46.     PDMA_Interrupt_Enable(PDMA1,PDMAFULLINT);
  47.     ENABLE_GLOBAL_INTERRUPT;
  48.     PDMA_Run(PDMA1);

  49.     while(!pdmaflag);
  50. #ifdef print_function
  51.     printf (" \n PDMA Tranfer Finish! 0x%bx", finalbuffer);
  52. #endif
  53.     while(1);
  54. }





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内存处理确实很高效
您需要登录后才可以回帖 登录 | 注册

本版积分规则

yiy

114

主题

1966

帖子

4

粉丝
快速回复 在线客服 返回列表 返回顶部