📄 dma3.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...... dma3.c
* DATE CREATED.. 01/11/2000
* LAST MODIFIED. 09/27/2000
\******************************************************************************/
#include <stdio.h>
#include <csl.h>
#include <csl_dma.h>
#include <csl_irq.h>
#include <csl_mcbsp.h>
/*----------------------------------------------------------------------------*/
/* In this example, we will be using the DMA in */
/* ABU mode to transfer data from a serial port */
/* The serial port will be placed in digital */
/* loopback mode for the transfer. */
/* These are the settings we need for the DMA */
/* mode control register, DMMCR, in order to */
/* perform the transfer */
/* MCBSP Control Regs */
/* SPCR10 */
/* #1000000000000000B, */
/* ;1~~~~~~~~~~~~~~~ DLB Loopback mode */
/* ;~00~~~~~~~~~~~~~ RJUST Right-justify/zer0-fill DRR's */
/* ;~~~00~~~~~~~~~~~ CLKSTP Continuous clock mode */
/* ;~~~~~000~~~~~~~~ N/A */
/* ;~~~~~~~~0~~~~~~~ DXENA DX delay off */
/* ;~~~~~~~~~0~~~~~~ ABIS A-bis mode disabled */
/* ;~~~~~~~~~~00~~~~ RINTM Interrupt generated on RRDY */
/* ;~~~~~~~~~~~~0~~~ RSYNCERR Clear sync error */
/* ;~~~~~~~~~~~~~0~~ RFULL */
/* ;~~~~~~~~~~~~~~0~ RRDY */
/* ;~~~~~~~~~~~~~~~0 RRST- Serial port in Reset */
/* SPCR20 */
/* #0000000000000000b */
/* ;000000~~~~~~~~~~ N/A */
/* ;~~~~~~0~~~~~~~~~ Free Free run disabled */
/* ;~~~~~~~0~~~~~~~~ Soft Disabled */
/* ;~~~~~~~~0~~~~~~~ FRST- Frame sync generator in reset*/
/* ;~~~~~~~~~0~~~~~~ GRST- Clock generator in reset */
/* ;~~~~~~~~~~00~~~~ XINTM Transmit interrupt on XRDY */
/* ;~~~~~~~~~~~~0~~~ XSYNCERR Clear sync error */
/* ;~~~~~~~~~~~~~0~~ XEMPTY- */
/* ;~~~~~~~~~~~~~~0~ XRDY */
/* ;~~~~~~~~~~~~~~~0 XRST- Transmitter in reset */
/* RCR1_0 */
/* #0000000001000000b */
/* ;0~~~~~~~~~~~~~~~ N/A */
/* ;~0000000~~~~~~~~ RFRLEN1 One frame (0h) */
/* ;~~~~~~~~010~~~~~ RWDLEN1 16-bit words */
/* ;~~~~~~~~~~~00000 N/A */
/* RCR2_0 */
/* #0000000000000001b */
/* ;0~~~~~~~~~~~~~~~ RPHASE Single phase frames */
/* ;~0000000~~~~~~~~ RFRLEN2 N/A */
/* ;~~~~~~~~000~~~~~ RWDLEN2 N/A */
/* ;~~~~~~~~~~~00~~~ RCOMPAND No companding */
/* ;~~~~~~~~~~~~~0~~ RFIG Receive frame ignore off */
/* ;~~~~~~~~~~~~~~01 RDATDLY 1-bit delay */
/* XCR1_0 */
/* #0000000001000000b */
/* ;0~~~~~~~~~~~~~~~ N/A */
/* ;~0000000~~~~~~~~ XFRLEN1 One word frames */
/* ;~~~~~~~~010~~~~~ XWDLEN1 16-bit words */
/* ;~~~~~~~~~~~00000 N/A */
/* XCR2_0 */
/* #0000000000000001b */
/* ;0~~~~~~~~~~~~~~~ XPHASE Single phase */
/* ;~0000000~~~~~~~~ XFRLEN2 N/A */
/* ;~~~~~~~~000~~~~~ XWDLEN2 N/A */
/* ;~~~~~~~~~~~00~~~ XCOMPAND No companding */
/* ;~~~~~~~~~~~~~0~~ XFIG Transmit frame ignore off */
/* ;~~~~~~~~~~~~~~01 XDATDLY 1-bit delay */
/* SRGR1_0 */
/* #0000000000000000b */
/* ;00000000~~~~~~~~ FWID Frame sync is one cycle wide */
/* ;~~~~~~~~00000000 CLKGDV Clock is divided by one */
/* SRGR2_0 */
/* #0010000000000000b */
/* ;0~~~~~~~~~~~~~~~ GSYNC No re-sync */
/* ;~0~~~~~~~~~~~~~~ CLKSP Normal clock edge polarity */
/* ;~~1~~~~~~~~~~~~~ CLKSM Clock from CPU source */
/* ;~~~0~~~~~~~~~~~~ FSGM Transmit due to DXR-to-XSR copy */
/* ;~~~~000000000000 FPER N/A */
/* PCR0 */
/* #0000101000000000b */
/* ;00~~~~~~~~~~~~~~ N/A */
/* ;~~0~~~~~~~~~~~~~ XIOEN No general purpose I/O's */
/* ;~~~0~~~~~~~~~~~~ RIOEN No general purpose I/O's */
/* ;~~~~1~~~~~~~~~~~ FSXM FSX from internal source */
/* ;~~~~~0~~~~~~~~~~ FSRM FSR from external source */
/* ;~~~~~~1~~~~~~~~~ CLKXM BCLKX from internal source */
/* ;~~~~~~~0~~~~~~~~ CLKRM BCLKR from BCLKX in DLB mode */
/* ;~~~~~~~~0~~~~~~~ N/A */
/* ;~~~~~~~~~0~~~~~~ CLKS_STAT */
/* ;~~~~~~~~~~0~~~~~ DX_STAT */
/* ;~~~~~~~~~~~0~~~~ DR_STAT */
/* ;~~~~~~~~~~~~0~~~ FSXP FSX is active high */
/* ;~~~~~~~~~~~~~0~~ FSRP FSR is active high */
/* ;~~~~~~~~~~~~~~0~ CLKXP Normal BCLKX polarity */
/* ;~~~~~~~~~~~~~~~0 CLKRP Normal BCLKR polarity */
/* Define global symbols and constants */
#define N 64
Uint16 src[N];
DMA_Handle myhDma;
volatile Uint16 WaitForDma = TRUE;
/* Place buufer in its own section, since his must reside in DMA */
/* Memory Map. Check your device datasheet for valid ranges of */
/* DMA memory. */
#pragma DATA_SECTION(buffer, "dmaMem")
Uint16 buffer[N];
/* Get Reference for strat of interrupt vector table */
/* This symbol is define in file, vectors.s54 */
extern void VECSTART(void);
/* Funcion prototypes */
interrupt void dmaIsr (void);
void taskFunc(void);
/* These are the settings we need for the DMA mode control register */
/* (DMMCR) */
/* DMMCR0 = 0x504Du */
/* #0101000001001101b */
/* ;0~~~~~~~~~~~~~~~ (AUTOINIT) Autoinitialization disabled */
/* ;~1~~~~~~~~~~~~~~ (DINM) Interrupts masked */
/* ;~~0~~~~~~~~~~~~~ (IMOD) N/A */
/* ;~~~1~~~~~~~~~~~~ (CTMOD) ABU mode */
/* ;~~~~0~~~~~~~~~~~ N/A */
/* ;~~~~~000~~~~~~~~ (SIND) No modification */
/* ;~~~~~~~~01~~~~~~ (DMS) Source in data space */
/* ;~~~~~~~~~~0~~~~~ N/A */
/* ;~~~~~~~~~~~011~~ (DIND) Post increment with IDX0 */
/* ;~~~~~~~~~~~~~~01 (DMD) Destination in data space */
/* These are the settings needed for the DMA sync and frame */
/* count register, DMSFC */
/* DMSFC0 = 0x1000u */
/* #0001000000000000b */
/* ;0001~~~~~~~~~~~~ (DSYN) Sync with REVT0 */
/* ;~~~~0~~~~~~~~~~~ (DBLW) Single-word mode */
/* ;~~~~~000~~~~~~~~ N/A */
/* ;~~~~~~~~00000000 (Frame Count) FrameCount = 0h(one frame)*/
/* Create a configuration structure for initializing the MCBSP */
/* in digital loopback mode, with 16 bit transfers */
MCBSP_Config my_mcbspConfig = {
MCBSP_SPCR1_RMK(
MCBSP_SPCR1_DLB_ON,
MCBSP_SPCR1_RJUST_DEFAULT,
MCBSP_SPCR1_CLKSTP_DISABLE,
MCBSP_SPCR1_DXENA_DEFAULT,
MCBSP_SPCR1_RINTM_RRDY,
MCBSP_SPCR1_RRST_DISABLE
), /* SPCR1 */
MCBSP_SPCR2_RMK(
MCBSP_SPCR2_FREE_NO,
MCBSP_SPCR2_SOFT_NO,
MCBSP_SPCR2_FRST_FSG,
MCBSP_SPCR2_GRST_CLKG,
MCBSP_SPCR2_XINTM_XRDY,
MCBSP_SPCR2_XRST_DISABLE
), /* SPCR2 */
MCBSP_RCR1_RMK(
MCBSP_RCR1_RFRLEN1_OF(0),
MCBSP_RCR1_RWDLEN1_16BIT
), /* RCR1 */
MCBSP_RCR2_RMK(
MCBSP_RCR2_RPHASE_SINGLE,
MCBSP_RCR2_RFRLEN2_OF(0),
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -