积分规则 网站地图 帮助中心    
嵌入式软件 单 片 机 DSP 存储器 传感控制 光电显示
嵌入式硬件 CPLD/FPGA SOPC AD/DA 接口电路 模拟设计
I C设计 通信产品 汽车电子 电源产品 消费电子 数控系统
工业控制 军工/航天 安防产品 医疗电子 计算机外设 测试测量
供应 I C
求购 公司库

  IC 求购 销售 公司 论文 DATASHEET 参考设计 论坛
当前位置: 电子技术 >> DSP >> DSP代码示例
  相关分类: 应用论文 | TI DSP | 新产品 | 算法 | 下载 | DSP代码示例 | ADI DSP | freescale DSP |
实现MCBSP与EDMA之间的数据传输(解决DSP的资源消耗问题)
 
作者:未知   来源:互联网    点击数:962   更新时间:2007-2-7
您可以添加到网摘 让更多人关注此文章:

    

/*???????????????????????????????????????????????????????????????????????????????*/
/* ac97codec.c V1.00 */
/* Copyright (c) 2001 Texas Instruments Incorporated */
/*???????????????????????????????????????????????????????????????????????????????*/
/*
6/12/01: Vassos S. Soteriou
ac97codec.c:
This program sets the McBSP of the TMS320C6000 devices as a digital
controller for an Audio Codec 1997 device. This program supports
all the Texas Instruments TMS320C6000 DSPs, those that use the DMA
controller or the Enhanced DMA controller (EDMA). For those that use
the DMA controller, DMA channels 1 and 2 service the McBSP.
CLKX, CLKR are generated using the CLKS clock.
FSX is the output that drives the codec’s frame syncs.
In the case of a DMA transfer, the vecs.asm assembly code file is
used to hookup the c_int11() and c_int09() ISRs to the corresponding
interrupts. Channel 1 is hooked up to interrupt 9 for data receive,
channel 2 is hooked up to interrupt 11 for data transmit, the DMA
controller has individual interrupts for each DMA channel. The EDMA
controller, however, generates a single interrupt to the CPU (EDMA_INT)
on behalf of all 16 channels (C621x/C671x) or 64 channels (C64x). The
various control registers and bit fields facilitate EDMA interrupt
generation. CPU_INT8 is responsible for all the EDMA channels
The sample code is based on TI’s CSL 2.0. Please refer to the TMS320C6000
Chip Support Library API User’s Guide for further information.
*/
/* Chip definition, change this accordingly */
#define CHIP_6415 1
/* Include files */
#include <c6x.h>
#include <csl.h> /* CSL library */
#include <csl_dma.h> /* DMA_SUPPORT */
#include <csl_edma.h> /* EDMA_SUPPORT */
#include <csl_irq.h> /* IRQ_SUPPORT */
#include <csl_mcbsp.h> /* MCBSP_SUPPORT */
#include <csl_timer.h> /* TIMER_SUPPORT */
/*???????????????????????????????????????????????????????????????????????????????*/
/* Define constants */
#define FALSE 0
#define TRUE 1
#define DMA_AC97 8
#define XFER_TYPE DMA_AC97
#define BUFFER_SIZE 256
#define ELEMENT_COUNT 13 /* Do not change this, AC’97 protocol */
#define FRAME_COUNT 10 /* Change this to desired value */
/* Global variables used in interrupt ISRs */
volatile int recv0_done = FALSE;
volatile int xmit0_done = FALSE;
/*???????????????????????????????????????????????????????????????????????????????*/
/* Declare CSL objects */
MCBSP_Handle hMcbsp0; /* Handles for McBSP */

//#if (EDMA_SUPPORT) /* Handles for EDMA */
EDMA_Handle hEdma1;
EDMA_Handle hEdma2;
EDMA_Handle hEdmadummy;
//#endif
TIMER_Handle hTimer0; /* Handle for TIMER0 */
/*???????????????????????????????????????????????????????????????????????????????*/
/* External functions and function prototypes */
void init_mcbsp0_ac97(void); /* Function prototypes */
//void set_interrupts_dma(void);
void set_interrupts_edma(void);
/* Inlcude the vector table to call the IRQ ISRs hookup */
extern far void vectors();
/*???????????????????????????????????????????????????????????????????????????????*/
/* main() */
/*???????????????????????????????????????????????????????????????????????????????*/
void main(void)
{
/* Declaration of local variables */
static int element_count, frame_count, xfer_type;
int delay_count = 0;
static Uint32 dmaInbuff[BUFFER_SIZE]; /* buffer for DMA supporting devices */
static Uint32 dmaOutbuff[BUFFER_SIZE];
static Uint32 edmaInbuff[BUFFER_SIZE]; /* buffer for EDMA supporting devices */
static Uint32 edmaOutbuff[BUFFER_SIZE];
IRQ_setVecs(vectors); /* point to the IRQ vector table */
element_count = ELEMENT_COUNT;
frame_count = FRAME_COUNT;
xfer_type = XFER_TYPE;
/* initialize the CSL library */
CSL_init();
/* Reset AC97 device */
/* Handle to TIMER 0, reset it upon open */
hTimer0 = TIMER_open(TIMER_DEV0, TIMER_OPEN_RESET);
TIMER_setDataOut(hTimer0,0); /* Write a 0 to the TOUT0 */
TIMER_start(hTimer0); /* Need to be 0 for at least 1 usec */
init_mcbsp0_ac97();
/* Enable sample rate generator GRST=1 */
MCBSP_enableSrgr(hMcbsp0); /* Handle to SRGR ‘ */
switch (xfer_type) {
case DMA_AC97:
 
//#if (EDMA_SUPPORT) /* For EDMA supporting devices */
EDMA_clearPram(0x00000000); /* Clear PaRAM RAM of the EDMA */
set_interrupts_edma();
//#endif
/*???????????????????????????????????????????????????????????????????????????????*/
/* EDMA channels 12 and 13 config structures */
/*???????????????????????????????????????????????????????????????????????????????*/
//#if (EDMA_SUPPORT) /* for EDMA supporting devices */
hEdma1 = EDMA_open(EDMA_CHA_REVT0, EDMA_OPEN_RESET);
EDMA_configArgs(hEdma1,

//#if (C64_SUPPORT)
EDMA_OPT_RMK(
EDMA_OPT_PRI_HIGH, /* High priority EDMA */
EDMA_OPT_ESIZE_32BIT, /* Element size 32 bits */
EDMA_OPT_2DS_DEFAULT,
EDMA_OPT_SUM_DEFAULT,
EDMA_OPT_2DD_DEFAULT,
EDMA_OPT_DUM_INC, /* Destination increment by element size */
EDMA_OPT_TCINT_YES, /* Enable Transfer Complete Interrupt */
EDMA_OPT_TCC_OF(13), /* TCCINT = 0xD, REVT0 */
EDMA_OPT_TCCM_DEFAULT,
EDMA_OPT_ATCINT_DEFAULT,
EDMA_OPT_ATCC_DEFAULT,
EDMA_OPT_PDTS_DEFAULT,
EDMA_OPT_PDTD_DEFAULT,
EDMA_OPT_LINK_YES, /* Enable linking to NULL table */
EDMA_OPT_FS_NO
),
//#endif
EDMA_SRC_RMK(MCBSP_ADDRH(hMcbsp0, DRR)), /* src to DRR0 */
EDMA_CNT_RMK(0, frame_count * element_count),/* no. of elements */
/* Optionally replace the above with the following line */
/* EDMA_CNT_RMK(frame_count, element_count), */
EDMA_DST_RMK((Uint32)edmaInbuff), /* dst addr to edmaInbuff */
EDMA_IDX_RMK(0,0),
EDMA_RLD_RMK(0,0)
);
hEdma2 = EDMA_open(EDMA_CHA_XEVT0, EDMA_OPEN_RESET);
EDMA_configArgs(hEdma2,

//#if(C64_SUPPORT)
EDMA_OPT_RMK( /* For 64x devices only */
EDMA_OPT_PRI_HIGH, /* High priority EDMA */
EDMA_OPT_ESIZE_32BIT, /* Element size 32 bits */
EDMA_OPT_2DS_DEFAULT,
EDMA_OPT_SUM_INC, /* Source increment by element size */
EDMA_OPT_2DD_DEFAULT,
EDMA_OPT_DUM_DEFAULT,
EDMA_OPT_TCINT_YES, /* Enable Transfer Complete Interrupt */
EDMA_OPT_TCC_OF(12), /* TCCINT = 0xC, XEVT0 */
EDMA_OPT_TCCM_DEFAULT,
EDMA_OPT_ATCINT_DEFAULT,
EDMA_OPT_ATCC_DEFAULT,
EDMA_OPT_PDTS_DEFAULT,
EDMA_OPT_PDTD_DEFAULT,
EDMA_OPT_LINK_YES, /* Enable linking to NULL table */
EDMA_OPT_FS_NO
),
//#endif
EDMA_SRC_RMK((Uint32)edmaOutbuff), /*src to edmaOutbuff */
EDMA_CNT_RMK(0,frame_count * element_count), /* set no. of elements */
/* Optionally replace the above with the following line */
/* EDMA_CNT_RMK(frame_count, element_count), */
EDMA_DST_RMK(MCBSP_ADDRH(hMcbsp0, DXR)), /* dst addr to DXR0 */
EDMA_IDX_RMK(0,0),
EDMA_RLD_RMK(0,0)
);
hEdmadummy = EDMA_allocTable(?1); /* Dynamically allocates PaRAM RAM table */
EDMA_configArgs(hEdmadummy, /* Dummy or Terminating Table in PaRAM */
0x00000000, /* Terminate EDMA transfers by linking to */
0x00000000, /* this NULL table */
0x00000000,
0x00000000,
0x00000000,
0x00000000
);
EDMA_link(hEdma1, hEdmadummy); /* Link terminating event to the EDMA event */
EDMA_link(hEdma2, hEdmadummy);
EDMA_enableChannel(hEdma1); /* Enable EDMA channels */
EDMA_enableChannel(hEdma2);
//#endif /* end for EDMA supporting devices */
}
/* make sure TOUT0 was low for >++ 1 usec */
for (delay_count = 0 ; delay_count < 500 ; delay_count++);
TIMER_setDataOut(hTimer0,1); /* Write a 1 to the TOUT0 */
/* wait for BITCLK to start */
for (delay_count = 0 ; delay_count <100 ; delay_count++);
MCBSP_enableRcv(hMcbsp0); /* Enable McBSP channel */
MCBSP_enableXmt(hMcbsp0); /* McBSP port 0 as the transmitter/receiver */
MCBSP_enableFsync(hMcbsp0); /* Enable frame sync for the McBSP */

/* To flag an interrupt to the CPU when EDMA transfer/receive is done */
/* Transfer completion interrupt 12 and 13 set flag = 1 when set */
//#if (EDMA_SUPPORT)
while (!xmit0_done || !recv0_done);
//#endif
MCBSP_close(hMcbsp0); /* close McBSP port */
//#if (EDMA_SUPPPORT)
EDMA_close(hEdma1); /* close EDMA channels */
EDMA_close(hEdma2);
EDMA_close(hEdmadummy);
//#/endif
TIMER_close(hTimer0); /* close TIMER 0 */
} /* end main, progam ends here */
/*???????????????????????????????????????????????????????????????????????????????*/
/* init_mcbsp0_ac97() */
/*???????????????????????????????????????????????????????????????????????????????*/
/* MCBSP Config structure */
/* Setup the MCBSP_0 for transfers with the AC97 codec*/
void
init_mcbsp0_ac97(void)
{
MCBSP_Config mcbspCfg0 = {
//#if (EDMA_SUPPORT)
MCBSP_SPCR_RMK(
MCBSP_SPCR_FREE_DEFAULT, /* All fields in SPCR set to default values */
MCBSP_SPCR_SOFT_DEFAULT,
MCBSP_SPCR_FRST_DEFAULT,
MCBSP_SPCR_GRST_DEFAULT,
MCBSP_SPCR_XINTM_DEFAULT,
MCBSP_SPCR_XSYNCERR_DEFAULT,
MCBSP_SPCR_XRST_DEFAULT,
MCBSP_SPCR_DLB_DEFAULT,
MCBSP_SPCR_RJUST_DEFAULT,
MCBSP_SPCR_CLKSTP_DEFAULT,
MCBSP_SPCR_DXENA_DEFAULT,
MCBSP_SPCR_RINTM_DEFAULT,
MCBSP_SPCR_RSYNCERR_DEFAULT,
MCBSP_SPCR_RRST_DEFAULT
),
//#endif

//#if (EDMA_SUPPORT)
MCBSP_RCR_RMK(
MCBSP_RCR_RPHASE_DUAL, /* Dual phase receive frame */
MCBSP_RCR_RFRLEN2_OF(0xB), /* frame length =12 elements */
MCBSP_RCR_RWDLEN2_20BIT, /* receive elements = 20 bits*/
MCBSP_RCR_RCOMPAND_DEFAULT,
MCBSP_RCR_RFIG_DEFAULT,
MCBSP_RCR_RDATDLY_1BIT, /* 1?bit receive data delay */
MCBSP_RCR_RFRLEN1_OF(0x0), /* frame length of 1 element */
MCBSP_RCR_RWDLEN1_16BIT, /* receive elements = 16bits */
MCBSP_RCR_RWDREVRS_DEFAULT
),
//#endif

//#if (EDMA_SUPPORT)
MCBSP_XCR_RMK(
MCBSP_XCR_XPHASE_DUAL, /* Dual phase transmit frame */
MCBSP_XCR_XFRLEN2_OF(0xB), /* frame length =12 elements */
MCBSP_XCR_XWDLEN2_20BIT,
MCBSP_XCR_XCOMPAND_DEFAULT,
MCBSP_XCR_XFIG_DEFAULT,
MCBSP_XCR_XDATDLY_1BIT, /* 1?bit transmit data delay */
MCBSP_XCR_XFRLEN1_OF(0x0), /* frame length of 1 element */
MCBSP_XCR_XWDLEN1_16BIT, /* receive elements = 16bits */
MCBSP_XCR_XWDREVRS_DEFAULT
),
//#endif

MCBSP_SRGR_RMK(
MCBSP_SRGR_GSYNC_FREE, /* Free running driven by CLKS */
MCBSP_SRGR_CLKSP_DEFAULT,
MCBSP_SRGR_CLKSM_CLKS, /* External clock source, CLKS, deriv
CLKSM */
MCBSP_SRGR_FSGM_FSG, /* FSX driven by SRG frame sync signal */
MCBSP_SRGR_FPER_OF(0xFF), /* Frame period is 256 CLKS 12.288MHz
periods */
MCBSP_SRGR_FWID_OF(0xF), /* Frame sync signal width = 16 BITCLK */
MCBSP_SRGR_CLKGDV_OF(0) /* CLKG same freq. as SRGR input clock CLKS */
),
//#if (C64_SUPPORT)
MCBSP_MCR_RMK( /* only for 64x */
MCBSP_MCR_XMCME_DEFAULT, /* All fields in MCR set to default values */
MCBSP_MCR_XPBBLK_DEFAULT,
MCBSP_MCR_XPABLK_DEFAULT,
MCBSP_MCR_XMCM_DEFAULT,
MCBSP_MCR_RPBBLK_DEFAULT,
MCBSP_MCR_RMCME_DEFAULT,
MCBSP_MCR_RPABLK_DEFAULT,
MCBSP_MCR_RMCM_DEFAULT
),


//#if (C64_SUPPORT)
MCBSP_RCERE0_RMK(0), /* Additional registers only for 64x */
MCBSP_RCERE1_RMK(0),
MCBSP_RCERE2_RMK(0),
MCBSP_RCERE3_RMK(0),
//#endif
//#if (C64_SUPPORT)
MCBSP_XCERE0_RMK(0), /* Additional registers only for 64x */
MCBSP_XCERE1_RMK(0),
MCBSP_XCERE2_RMK(0),
MCBSP_XCERE3_RMK(0),
//#endif
MCBSP_PCR_RMK(
MCBSP_PCR_XIOEN_DEFAULT,
MCBSP_PCR_RIOEN_DEFAULT,
MCBSP_PCR_FSXM_INTERNAL, /* Frame sync generated internally */
MCBSP_PCR_FSRM_INTERNAL, /* Frame sync generated internally */
MCBSP_PCR_CLKXM_DEFAULT,
MCBSP_PCR_CLKRM_DEFAULT,
MCBSP_PCR_CLKSSTAT_DEFAULT,
MCBSP_PCR_DXSTAT_DEFAULT,
MCBSP_PCR_FSXP_ACTIVEHIGH, /* FSX is active high */
MCBSP_PCR_FSRP_ACTIVEHIGH, /* FSR is active high */
MCBSP_PCR_CLKXP_DEFAULT,
MCBSP_PCR_CLKRP_DEFAULT
)
};
hMcbsp0 = MCBSP_open(MCBSP_DEV0, MCBSP_OPEN_RESET); /* McBSP port 0 */
MCBSP_config(hMcbsp0, &mcbspCfg0);
}
/*???????????????????????????????????????????????????????????????????????????????*/
/* set_interrupts_edma() */
/*???????????????????????????????????????????????????????????????????????????????*/
//#if (EDMA_SUPPORT)
void /* Set the interrupts */
set_interrupts_edma(void) /* if the device supports EDMA */
{
IRQ_nmiEnable();
IRQ_globalEnable();
IRQ_reset(IRQ_EVT_EDMAINT);
IRQ_disable(IRQ_EVT_EDMAINT);
EDMA_intDisable(12); /* ch 12 for McBSP transmit event XEVT0 */
EDMA_intDisable(13); /* ch 13 for McBSP receive event REVT0 */
IRQ_clear(IRQ_EVT_EDMAINT);
EDMA_intClear(12);
EDMA_intClear(13);
IRQ_enable(IRQ_EVT_EDMAINT);
EDMA_intEnable(12);
EDMA_intEnable(13);
return;
}
//#endif
/*???????????????????????????????????????????????????????????????????????????????*/

/*???????????????????????????????????????????????????????????????????????????????*/
/*interrupt void
c_int11(void)
{
xmit0_done = TRUE;
return;
}
interrupt void
c_int09(void)
{
recv0_done = TRUE;
return;
}*/
interrupt void /* vecs.asm hooks this up to IRQ 08 */
c_int08(void) /* for the EDMA */
{
//#if (EDMA_SUPPORT)
if (EDMA_intTest(12))
{
xmit0_done = TRUE;
EDMA_intClear(12); /* clear CIPR bit so future interrupts can be recognized */
}
else if (EDMA_intTest(13))
{
recv0_done = TRUE;
EDMA_intClear(13); /* clear CIPR bit so future interrupts can be recognized */
}
//#endif
return;
}
/*???????????????????????End of ac97codec.c?????????????????????????????????????*/



相关文章
· 科技奥运与计算机技术的应用[425]
· Electromedical[2693]
· 患者监控[2743]
· 基于TMS320LF2407A DSP的心电监护系统研究[3187]
· 用S3C2410实现三导联远程心电监护系统[3097]
热门评论排行
·VHDL设计中电路简化问题的
·ARM嵌入式系统基础教程(N
·江苏嵌入式Linux教育培训
·ARM处理器应用开发4步骤
·锐极LINUX驱动培训班定于

文章评论
    没有任何评论
*只显示最新10条评论。评论内容只代表网友观点,与本站立场无关。更多评论
发表评论
  * 请先[登陆]再进行评论,谢谢。
评分: 1分 2分 3分 4分 5分
内容: *
发帖须知:
一.所发文章必须遵守《互联网电子公告服务管理规定》;
二.严禁发布供求代理信息,公司介绍,产品信息等广告宣传信息;
三.严禁恶意重复发帖;
四.严禁对个人,实体,民族,国家等进行漫骂,污蔑,诽谤。
 
热点新闻 [更多]
 
严冬期如何发展半导体业 扩
2008年中国集成电路市场回顾与展望
分析师:亚洲芯片厂商库存远超预期
2008年基础电子业十大事件点评
Aptina并购智多微手机软件平台设
凌力尔特公司推出用于多核处理器的&n
安森美半导体任命麦满权为韩国及南亚区
Broadcom:半导体产业依然机会
飞思卡尔推i.MX51芯 
日立芯片守卫新年倒数计时晚会
 
热门下载 [更多]
 
[ PCB设计] Protel99教程下载
[ ] 手把手学单片机20个例
[ ] 单片机做的智能台灯
[ ] 单片机入门书
[ ] linux系统移植开发文档
[ ] IC卡的读写程序
[ ] 8051单片机C语言彻底应用
[ 常用软件] 555定时器电路设计软件V1.2
[ 常用软件] 51定时器计算软件
[ ] ARM处理器应用开发4步骤
 
论坛新帖 [更多]
 
低价专业PCB打样 双面板20...
深圳市天漠科技超低价供应atm...
深圳市天漠科技超低价供应ARM...
[推荐]2.5米精度,高灵敏度...
830实验箱+电脑没有并口...
[原创]平望科技助力自服终端国...
低价专业PCB打样 双面板20...
[原创]低价专业PCB打样 双...
Bootloader for ...
【有奖调查】08-09嵌入式开...

 
赞助商 [更多]
 

ICP许可证号:[粤 05056597]
联系电话:010-82517432 82517615 传真: 010-82517615

版权所有 Copyright © 2006 嵌入式技术网