📄 dma5.c
字号:
/*
* Copyright 2003 by Texas Instruments Incorporated.
* All rights reserved. Property of Texas Instruments Incorporated.
* Restricted rights to use, duplicate or disclose this code are
* granted through contract.
*
*/
/* "@(#) DSP/BIOS 4.90.150 04-08-03 (barracuda-m02)" */
/******************************************************************************\
* Copyright (C) 2000 Texas Instruments Incorporated.
* All Rights Reserved
*------------------------------------------------------------------------------
* FILENAME...... dma1b.c
* DATE CREATED.. 01/11/2000
* LAST MODIFIED. 09/27/2000
\******************************************************************************/
#include <stdio.h>
#include <csl.h>
#include <csl_dma.h>
/*----------------------------------------------------------------------------*/
/* create a data from DMA transfer */
#define N 16
/* Place data in separate section to ensure placement */
/* within the DMA memory space defined for the device.*/
/* The address ranges chosen for this example in the */
/* linker command file place src and dst within the */
/* DMA memory map for the TMS320C5402. When modifying */
/* this example to run on a different C54x target, */
/* please check the datasheet for your specific */
/* device to make sure that the src and dst addresses */
/* for your transfer are assigned to a valid DMA */
/* memory space. */
#pragma DATA_SECTION(src,"dmaMem")
Uint16 src[N];
#pragma DATA_SECTION(dst, "dmaMem")
Uint16 dst[N];
/* In this example, we will be effecting a DMA */
/* transfer from DATA to DATA space in internal */
/* memory. The DMA will operate in multi-frame */
/* mode and we will poll for DMA operation */
/* complete. */
/* These are the settings we need for the DMA */
/* mode control register, DMMCR, in order to */
/* perform the transfer */
/* DMMCR0 = 0x0145u */
/* #0000000101000101b */
/* ;0~~~~~~~~~~~~~~~ (AUTOINIT) No Autoinit */
/* ;~0~~~~~~~~~~~~~~ (DINM) No Interrupts */
/* ;~~0~~~~~~~~~~~~~ (IMOD) N/A */
/* ;~~~0~~~~~~~~~~~~ (CTMOD) Multi-frame on */
/* ;~~~~0~~~~~~~~~~~ N/A */
/* ;~~~~~001~~~~~~~~ (SIND) Src addr Post-incr */
/* ;~~~~~~~~01~~~~~~ (DMS) Src in data space */
/* ;~~~~~~~~~~0~~~~~ N/A */
/* ;~~~~~~~~~~~001~~ (DIND) Dst addr Post-incr */
/* ;~~~~~~~~~~~~~~01 (DMD) Dst in data space */
/* These are the settings required for DMA sync and */
/* frame count register, DMSFC */
/* DMSFC0 = 0x0000u */
/* */
/* #0000000000000000b */
/* ;0000~~~~~~~~~~~~ (DSYN) No sync event */
/* ;~~~~0~~~~~~~~~~~ (DBLW) Single-word mode */
/* ;~~~~~000~~~~~~~~ N/A */
/* ;~~~~~~~~00000000 (Frame Count) = 0 (one frame) */
/* Declare DMA Handle */
DMA_Handle myhDma;
void taskFunc();
/*----------------------------------------------------------------------------*/
void main() {
Uint16 i;
/* Initialize CSL library, this step is required */
CSL_init();
/* Set Src values and Clear destination */
for (i=0; i<= N-1; i++) {
src[i] = 0xBABA;
dst[i] = 0;
}
/* Call example task/function */
taskFunc();
}
/*----------------------------------------------------------------------------*/
void taskFunc() {
/* Create a DMA handle pointer */
Uint16 err = 0;
Uint16 i;
printf("<DMA5>\n");
/* Open DMA channel 0, to use for this transfer */
myhDma = DMA_open(DMA_CHA0, 0);
/* Call DMA_config function to write our configuration */
/* values to DMA channel control registers */
/* In Example DMA1A, we defined a configuration structure */
/* and called DMA_config function, passing the config */
/* structure as argument. In this example, DMA1B, we call */
/* the DMA_configArgs function, passing each register */
/* value as an argument to the function. */
DMA_configArgs(
myhDma,
1 , /* Priority */
DMA_DMMCR_RMK(
DMA_DMMCR_AUTOINIT_OFF,
DMA_DMMCR_DINM_OFF,
DMA_DMMCR_IMOD_FULL_ONLY,
DMA_DMMCR_CTMOD_MULTIFRAME,
DMA_DMMCR_SIND_POSTINC,
DMA_DMMCR_DMS_DATA,
DMA_DMMCR_DIND_POSTINC,
DMA_DMMCR_DMD_DATA
), /* DMMCR */
DMA_DMSFC_RMK(
DMA_DMSFC_DSYN_NONE,
DMA_DMSFC_DBLW_OFF,
DMA_DMSFC_FRAMECNT_OF(0)), /* DMSFC */
(DMA_AdrPtr)&src, /* DMSRC */
(DMA_AdrPtr)&dst, /* DMDST */
(Uint16)(N-1) /* DMCTR */
);
/* Call DMA_start to begin the data transfer */
DMA_start(myhDma);
/* Poll DMA status too see if its done */
while(DMA_getStatus(myhDma));
/* Check the values to make sure DMA transfer is */
/* correct. */
for (i = 0; i <= N-1; i++) {
if (dst[i] != 0xBABA) {
++err;
}
}
/* We are done, so close DMA channel */
DMA_close(myhDma);
printf ("Multi-frame operation of DMA\n");
printf("%s\n",err?"TEST FAILED":"TEST PASSED");
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -