在线咨询
eetop公众号 创芯大讲堂 创芯人才网
切换到宽版

EETOP 创芯网论坛 (原名:电子顶级开发网)

手机号码,快捷登录

手机号码,快捷登录

找回密码

  登录   注册  

快捷导航
搜帖子
查看: 11448|回复: 4

[原创] 请教大侠们一个问题 ????

[复制链接]
发表于 2009-3-29 17:02:07 | 显示全部楼层 |阅读模式

马上注册,结交更多好友,享用更多功能,让你轻松玩转社区。

您需要 登录 才可以下载或查看,没有账号?注册

x
本帖最后由 cjsb37 于 2013-4-29 08:56 编辑

下面是我在Visualdsp++中EZ-KIT LITE 环境下运行的源代码,这是可以的。可是在模拟环境下就出错了。请大侠,高手们看看,解决修改一下。
/**********************************************************/
/*                                                        */
/* bp.c                                                   */
/*                                                        */
/* Copyright (c) 2001 Analog Device, Inc.                 */
/*                                                        */
/**********************************************************/
/* ADSP-2106x System Register bit definitions */
#include <def21060.h>
#include <21060.h>
#include <signal.h>
#include <sport.h>
#include <macros.h>
#include <math.h>
#include <filters.h>
    /* DMA Chain pointer bit definitions */
#define CP_PCI 0x20000          /* Program-Controlled Interrupts bit */
#define CP_MAF 0x1ffff          /* Valid memory address field bits   */
#define SetIOP(addr, val)  (* (volatile int *) addr) = (val)
#define GetIOP(addr)       (* (volatile int *) addr)
/**********************************************************/
#define NUM_TAPS 256
float pm coeffs[5][NUM_TAPS] =
{
#include "fir.h"
};
float dm state[NUM_TAPS+1];
/**********************************************************/
#define SZ_regs_1847 16
int regs_1847[SZ_regs_1847] = {
/* Note that the MCE bit is maintained throughout initial
    programming to hold off premature autocalibration. */
0xc000,                 /* index 0 - left input control */
0xc100,                 /* index 1 - right input control */
0xc280,                 /* index 2 - left aux 1 input control */
0xc380,                 /* index 3 - right aux 1 input control */
0xc480,                 /* index 4 - left aux 2 input control */
0xc580,                 /* index 5 - right aux 2 input control */
0xc600,                 /* index 6 - left dac control */
0xc700,                 /* index 7 - right dac control */
0xc850,                 /* index 8 - data format */
0xc909,                 /* index 9 - interface configuration */
0xca00,                 /* index 10 - pin control */
0xcb00,                 /* index 11 - no register */
0xcc40,                 /* index 12 - miscellaneous information */
0xcd00,                 /* index 13 - digital mix control */
0xce00,                 /* index 14 - no register */
0x8f00};                /* index 15 - no register */
unsigned rx_buf[3];                          /* receive buffer */
unsigned tx_buf[3] = {0xcc40, 0, 0};         /* transmit buffer */
/* DMA chaining Transfer Control Blocks */
typedef struct {
   unsigned   lpath3;     /* for mesh mulitprocessing  */
   unsigned   lpath2;     /* for mesh multiprocessing  */
   unsigned   lpath1;     /* for mesh multiprocessing  */
   unsigned   db;         /* General purpose register  */
   unsigned   gp;         /* General purpose register  */
   unsigned** cp;         /* Chain Pointer to next TCB */
   unsigned   c;          /* Count register            */
   unsigned   im;         /* Index modifier register   */
   unsigned * ii;         /* Index register            */
} _tcb;
_tcb rx_tcb = {0, 0, 0, 0, 0, 0, 3, 1, 0};      /* receive tcb */
_tcb tx_tcb = {0, 0, 0, 0, 0, 0, 3, 1, 0};      /* transmit tcb */
int cmd_blk[8];                                 /* command block */
static int xmit_count;
static int * xmit_ptr;
static int source=0;
static int filter=1;
/**********************************************************/
/*                                                        */
/* Periodic timer interrupt                               */
/*                                                        */
/**********************************************************/
void timer_lo_prior( int sig_num )
{
    sig_num=sig_num;
    // Toggle flag 2 LED.
    set_flag(SET_FLAG2, TGL_FLAG);
}
/**********************************************************/
/*                                                        */
/* Serial port transmit DMA complete                      */
/*                                                        */
/**********************************************************/
void spt0_asserted( int sig_num )
{
    // Check if there are more commands left to transmit.
    if( xmit_count )
    {
        // If so, put the command into the transmit buffer and update count.
        tx_buf[0] = *xmit_ptr++;
        xmit_count--;
    }
}
/**********************************************************/
/*                                                        */
/* Serial port receive DMA complete                       */
/*                                                        */
/**********************************************************/
void spr0_asserted( int sig_num )
{
    float filter_input;
    // Get sample from Codec or random noise.   
    if( source == 0 )
    {
        filter_input = rx_buf[1];
    }
    else
    {
        filter_input = rand() & 0x00003fff;
    }
    // Filter sample and output.
    if( filter )
        tx_buf[1] = fir( filter_input, &coeffs[filter][0], &state[0], (int)NUM_TAPS );
    else
        tx_buf[1] = filter_input;
    tx_buf[2] = tx_buf[1];
}
/**********************************************************/
/*                                                        */
/*                                                        */
/*                                                        */
/**********************************************************/
void setup_sports ( void )
{
    /* Configure SHARC serial port SPORT0 */
    /* Multichannel communications setup */
    sport0_iop.mtcs  = 0x00070007;       /* transmit on words 0,1,2,16,17,18 */
    sport0_iop.mrcs  = 0x00070007;       /* receive on words 0,1,2,16,17,18  */
    sport0_iop.mtccs = 0x00000000;       /* no companding on transmit        */
    sport0_iop.mrccs = 0x00000000;       /* no companding on receive         */
    /* TRANSMIT CONTROL REGISTER */
    /* STCTL0 <= 0x001c00f2      */
    /* An alternate (and more efficient) way of doing this would be to   */
    /* write the 32-bit register all at once with a statement like this: */
    /*        SetIOP(STCTL0, 0x001c00f2);                                */
    /* But the following is more descriptive...                          */
    sport0_iop.txc.mfd   = 1;    /* multichannel frame delay (MFD)       */
    sport0_iop.txc.schen = 1;    /* Tx DMA chaining enable               */
    sport0_iop.txc.sden  = 1;    /* Tx DMA enable                        */
    sport0_iop.txc.lafs  = 0;    /* Late TFS (alternate)                 */
    sport0_iop.txc.ltfs  = 0;    /* Active low TFS                       */
    sport0_iop.txc.ditfs = 0;    /* Data independent TFS                 */
    sport0_iop.txc.itfs  = 0;    /* Internally generated TFS             */
    sport0_iop.txc.tfsr  = 0;    /* TFS Required                         */
    sport0_iop.txc.ckre  = 0;    /* Data and FS on clock rising edge     */
    sport0_iop.txc.gclk  = 0;    /* Enable clock only during transmission*/
    sport0_iop.txc.iclk  = 0;    /* Internally generated Tx clock        */
    sport0_iop.txc.pack  = 0;    /* Unpack 32b words into two 16b tx's   */
    sport0_iop.txc.slen  = 15;   /* Data word length minus one           */
    sport0_iop.txc.sendn = 0;    /* Data word endian 1 = LSB first       */
    sport0_iop.txc.dtype = SPORT_DTYPE_RIGHT_JUSTIFY_SIGN_EXTEND;
    /* Data type specifier                  */
    sport0_iop.txc.spen  = 0;    /* Enable (clear for MC operation)      */
    /* RECEIVE CONTROL REGISTER */
    /* SRCTL0 <= 0x1f8c20f2     */
    sport0_iop.rxc.nch   = 31;   /* multichannel number of channels - 1  */
    sport0_iop.rxc.mce   = 1;    /* multichannel enable                  */
    sport0_iop.rxc.spl   = 0;    /* Loop back configure (test)           */
    sport0_iop.rxc.d2dma = 0;    /* Enable 2-dimensional DMA array       */
    sport0_iop.rxc.schen = 1;    /* Rx DMA chaining enable               */
    sport0_iop.rxc.sden  = 1;    /* Rx DMA enable                        */
    sport0_iop.rxc.lafs  = 0;    /* Late RFS (alternate)                 */
    sport0_iop.rxc.ltfs  = 0;    /* Active low RFS                       */
    sport0_iop.rxc.irfs  = 0;    /* Internally generated RFS             */
    sport0_iop.rxc.rfsr  = 1;    /* RFS Required                         */
    sport0_iop.rxc.ckre  = 0;    /* Data and FS on clock rising edge     */
    sport0_iop.rxc.gclk  = 0;    /* Enable clock only during transmission*/
    sport0_iop.rxc.iclk  = 0;    /* Internally generated Rx clock        */
    sport0_iop.rxc.pack  = 0;    /* Pack two 16b rx's into 32b word      */  
    sport0_iop.rxc.slen  = 15;   /* Data word length minus one           */
    sport0_iop.rxc.sendn = 0;    /* Data word endian 1 = LSB first       */
    sport0_iop.rxc.dtype = SPORT_DTYPE_RIGHT_JUSTIFY_SIGN_EXTEND;
    /* Data type specifier                  */
    sport0_iop.rxc.spen = 0;     /* Enable (clear for MC operation)      */
    /* Enable sport0 xmit & rcv irqs (DMA enabled) */
    interrupt(SIG_SPR0I, spr0_asserted);
    interrupt(SIG_SPT0I, spt0_asserted);
    /* Set up Transmit Transfer Control Block for chained DMA */
    tx_tcb.ii = tx_buf;          /* DMA source buffer address                */
    tx_tcb.cp = &tx_tcb.ii;      /* define ptr to next TCB (point to self)   */
    SetIOP(CP2, (((int)&tx_tcb.ii) & CP_MAF) | CP_PCI);
    /* define ptr to current TCB (kick off DMA) */
    /* (SPORT0 transmit uses DMA ch 2)          */
    /* Set up Receive Transfer Control Block for chained DMA */
    rx_tcb.ii = rx_buf;          /* DMA destination buffer address           */
    rx_tcb.cp = &rx_tcb.ii;      /* define ptr to next TCB (point to self)   */
    SetIOP(CP0, (((int)&rx_tcb.ii) & CP_MAF) | CP_PCI);
    /* define ptr to current TCB (kick off DMA) */
    /* (SPORT0 receive uses DMA ch 0)           */
}
/**********************************************************/
/*                                                        */
/*                                                        */
/*                                                        */
/**********************************************************/
void send_1847_config_cmds( void )
{
    // Set up pointer and counter to transmit commands.
    xmit_ptr   = regs_1847;
    xmit_count = SZ_regs_1847;
    // Wait for all commands to be transmitted.
    while( xmit_count )
        idle();
    // Wait for AD1847 autocal to start.
    while( !(rx_buf[0] & 0x0002) )
        idle();
    // Wait for AD1847 autocal to finish.
    while( rx_buf[0] & 0x0002 )
        idle();
    return;
}
/**********************************************************/
/*                                                        */
/*                                                        */
/*                                                        */
/**********************************************************/
void init_21k( void )
{
    // Disable timer and set rate to 4 Hz.
    timer_off();
    timer_set( 10000000, 10000000 );
    // Initialize pointer and counter to transmit commands.
    xmit_count = 0;
    xmit_ptr   = regs_1847;
    // Enable interrupt nesting.
    asm( "#include <def21060.h>" );
    asm( "bit set mode1 NESTM;"  );
    // Enable timer (low priority) interrupt.
    interrupt( SIG_TMZ, timer_lo_prior );
    // Turn flag LEDs off.
    set_flag( SET_FLAG2, SET_FLAG );
    return;
}
/**********************************************************/
/*                                                        */
/*                                                        */
/*                                                        */
/**********************************************************/
void main ( void )
{
    int i;
    int x;
    // Initialize state array for FIR filter.
    for( i=0 ; i<NUM_TAPS+1 ; i++ )
        state = 0.0;
    // Initialize some SHARC registers.
    init_21k();
    // Reset the Codec.
    set_flag( SET_FLAG0, CLR_FLAG );    /* Put CODEC into RESET  */
    for( x=0 ; x<0xffff ; x++ )         /* Hold CODEC in RESET */
        ;
    set_flag( SET_FLAG0, SET_FLAG );    /* Release CODEC from RESET */
    // Configure SHARC serial port.
    setup_sports();
   
    // Send setup commands to CODEC.
    send_1847_config_cmds();
    // Turn on all LEDs.
    set_flag(SET_FLAG2, CLR_FLAG);
    // Turn on the timer.
    timer_on();
    // Loop forever.
    for(;;)
    {
        idle();
    };
}
/**********************************************************/
/*                                                        */
/* End of bp.c                                            */
/*                                                        */
/**********************************************************/


出错代码为
----------------Configuration: bp - Debug----------------
.\061__ezkit_hdr.asm
[Warning pp0037] ".\061__ezkit_hdr.asm":21 Incompatible redefinition of macro '__ADSP21065L__'
Preprocessor finished with 0 error(s) 1 warning(s)
.\Bp.c
"D:\visual dsp++\21k\include\21060.h", line 172: cc1133: {D} warning: #warning
          directive: Use 21065l.h instead of 21060.h for 21065L compilations
  #warning Use 21065l.h instead of 21060.h for 21065L compilations
   ^
"Bp.c", line 96: cc0020:  error: identifier "SET_FLAG2" is undefined
      set_flag(SET_FLAG2, TGL_FLAG);
               ^
"Bp.c", line 96: cc0020:  error: identifier "TGL_FLAG" is undefined
      set_flag(SET_FLAG2, TGL_FLAG);
                          ^
"Bp.c", line 96: cc1080: {D} warning: Function does not have a full prototype
      set_flag(SET_FLAG2, TGL_FLAG);
      ^
"Bp.c", line 131: cc1080: {D} warning: Function does not have a full prototype
          filter_input = rand() & 0x00003fff;
                         ^
"Bp.c", line 174: cc0136:  error: struct "__sport_transmit_control_register"
          has no field "gclk"
      sport0_iop.txc.gclk  = 0;    /* Enable clock only during transmission*/
                     ^
"Bp.c", line 197: cc0136:  error: struct "__sport_receive_control_register"
          has no field "gclk"
      sport0_iop.rxc.gclk  = 0;    /* Enable clock only during transmission*/
                     ^
"Bp.c", line 239: cc1080: {D} warning: Function does not have a full prototype
          idle();
          ^
"Bp.c", line 243: cc1080: {D} warning: Function does not have a full prototype
          idle();
          ^
"Bp.c", line 247: cc1080: {D} warning: Function does not have a full prototype
          idle();
          ^
"Bp.c", line 260: cc1080: {D} warning: Function does not have a full prototype
      timer_off();
      ^
"Bp.c", line 261: cc1080: {D} warning: Function does not have a full prototype
      timer_set( 10000000, 10000000 );
      ^
"Bp.c", line 275: cc0020:  error: identifier "SET_FLAG2" is undefined
      set_flag( SET_FLAG2, SET_FLAG );
                ^
"Bp.c", line 275: cc0020:  error: identifier "SET_FLAG" is undefined
      set_flag( SET_FLAG2, SET_FLAG );
                           ^
"Bp.c", line 275: cc1080: {D} warning: Function does not have a full prototype
      set_flag( SET_FLAG2, SET_FLAG );
      ^
"Bp.c", line 298: cc0020:  error: identifier "SET_FLAG0" is undefined
      set_flag( SET_FLAG0, CLR_FLAG );    /* Put CODEC into RESET  */
                ^
"Bp.c", line 298: cc0020:  error: identifier "CLR_FLAG" is undefined
      set_flag( SET_FLAG0, CLR_FLAG );    /* Put CODEC into RESET  */
                           ^
"Bp.c", line 298: cc1080: {D} warning: Function does not have a full prototype
      set_flag( SET_FLAG0, CLR_FLAG );    /* Put CODEC into RESET  */
      ^
"Bp.c", line 301: cc0020:  error: identifier "SET_FLAG" is undefined
      set_flag( SET_FLAG0, SET_FLAG );    /* Release CODEC from RESET */
                           ^
"Bp.c", line 301: cc1080: {D} warning: Function does not have a full prototype
      set_flag( SET_FLAG0, SET_FLAG );    /* Release CODEC from RESET */
      ^
"Bp.c", line 310: cc0020:  error: identifier "SET_FLAG2" is undefined
      set_flag(SET_FLAG2, CLR_FLAG);
               ^
"Bp.c", line 310: cc1080: {D} warning: Function does not have a full prototype
      set_flag(SET_FLAG2, CLR_FLAG);
      ^
"Bp.c", line 313: cc1080: {D} warning: Function does not have a full prototype
      timer_on();
      ^
"Bp.c", line 318: cc1080: {D} warning: Function does not have a full prototype
          idle();
          ^
10 errors detected in the compilation of "Bp.c".
cc3089: fatal error: Compilation failed
Tool failed with exit/exception code: 1.
Build was unsuccessful.





发表于 2009-4-5 05:16:54 | 显示全部楼层
你没搞笑吧, 用VISUAL的环境写的代码拿去用。
发表于 2009-4-9 03:41:19 | 显示全部楼层

到底想说什么,有意思这样么

来的卡卡

有意思这样么

要说就说吧,楼主
发表于 2009-4-12 06:40:24 | 显示全部楼层

好贴好体贴,文章好好文章,报道

爱情”两字是我们生活中不可缺少的话题,男人与女人,一直是我们这些人茶余饭后的话题。也许可以说是无聊,但是乎人们已经习惯了这种人与人之的不可少的话题。那么,又有多少爱情可以无坚不催?可以经得起岁月的搓砣,是乎找不到更好的方式来形容那些废弃的爱情故事!爱情经不起时间的比较,经不起物质生活的比较,最终有多少对恋人在这种不实际的比较中失去自我?后悔一生呢?

我们隔壁有一对男女,最近为了钱的事和一些杂碎小事,争吵得不可开交,男孩在市内上班,平时工作比较忙,很少时间看到他,女孩在关外一家工厂做文职工作,一般两个星期才回来一次。可谓是聚少离多,便平日里看到他们的感情非常的要好,看着都让人嫉妒的甜蜜。女孩的性格很外向,经常与我们打成一片。而男孩的性格就有些内向了,很少说话,但看得出是个性格温柔的男孩。男孩在事业上没有多大的成就,但他对女孩的好,我们都可以证明了,生活还是可以这样不紧不慢,他给我们的感觉是一个比较踏实的人。这也是当时女孩选择他的原因了,生活可以平淡,但很温馨。

最近因经融危机,女孩的工厂在女孩跟部门主管有点矛盾后,没有挽留她继续做下去的意思,女孩因此又失业了。听说他们过年回家要订婚了,但他们没有一点充足的经济来做准备,这让女孩和男人陷入了苦恼之中,这种无型的压力促使着他们,这也许就是现实,有了这些压力,他们常常为了一些日常而吵架,相互不理解,不接受。女孩过来跟我和朋友说了一通话,我们都知道那些是气话,她说:“他又没钱,又没长相,什么都没有,我还这样跟着他,他却这样对我。没良心之类的话,看看别人什么什么….

代写论文
硕士论文
职称论文
论文代写
发表于 2011-3-19 11:18:59 | 显示全部楼层
加油加油
您需要登录后才可以回帖 登录 | 注册

本版积分规则

关闭

站长推荐 上一条 /2 下一条

小黑屋| 手机版| 关于我们| 联系我们| 隐私声明| EETOP 创芯网
( 京ICP备:10050787号 京公网安备:11010502037710 )

GMT+8, 2025-2-23 16:09 , Processed in 0.023414 second(s), 11 queries , Gzip On, Redis On.

eetop公众号 创芯大讲堂 创芯人才网
快速回复 返回顶部 返回列表