This thread has been locked.

If you have a related question, please click the "Ask a related question" button in the top right corner. The newly created question will be automatically linked to this question.

TMS320C6748的MCASP问题



您好

我用了一个MCASP的发送例程,以查询方式发送一个持续的单音,一切正常,但是在我开启了一个TIMER0 3:4的中断应用后,MCASP就不能发送了,为什么?需要我提供程序吗

  • timer中断正常吗?MCASP 发送标志位XDATA没置起来?
  • Shine Zhang:您好,您问我:timer中断正常吗?MCASP 发送标志位XDATA没置起来?回答是:timer中断正常,XGBLCTL中的所有位都置1了。
    我的问题和相关程序大致如下的
    MACSP以查询方式可连续发送一单音信号,但是启用定时器0后发送就无法进行了,定时器0的中断服务可正常实现,但是该服务和MACSP完全无关,它是按照约定计数在GP2[0]和GP2[8]引脚上分别输出50mS和100mS的周期方波。

    // 正弦波表(16bit)***************************************************************************
    static UINT16 sinetable[48] = {
    0x0000, 0x10b4, 0x2120, 0x30fb, 0x3fff, 0x4dea, 0x5a81, 0x658b,
    0x6ed8, 0x763f, 0x7ba1, 0x7ee5, 0x7ffd, 0x7ee5, 0x7ba1, 0x76ef,
    0x6ed8, 0x658b, 0x5a81, 0x4dea, 0x3fff, 0x30fb, 0x2120, 0x10b4,
    0x0000, 0xef4c, 0xdee0, 0xcf06, 0xc002, 0xb216, 0xa57f, 0x9a75,
    0x9128, 0x89c1, 0x845f, 0x811b, 0x8002, 0x811b, 0x845f, 0x89c1,
    0x9128, 0x9a76, 0xa57f, 0xb216, 0xc002, 0xcf06, 0xdee0, 0xef4c
    };

    // 因为时槽是16bit,所以这里将16bit正弦波表放进32bit的高端
    input_audio_32bit=(unsigned int *)0xc1000000;
    for(sample = 0; sample < 48; sample++)
    input_audio_32bit[sample]=(sinetable[sample]<< 16) ;


    // 主循环以查询方式发送.***************************************************************************
    while(1)
    {
    for (msec = 0; msec < 1000; msec++)
    {
    for (sample = 0; sample < 48; sample++)
    {

    // while (!CHKBIT(MCASP->SRCTL12, XRDY)) {} // 可用下局替代
    while (!CHKBIT(MCASP->XSTAT, XDATA)){} // 可用上句替代
    MCASP->XBUF12 = input_audio_32bit[sample];
    SETBIT(MCASP->XSTAT,XDATA); // 写1清除,不过此句好像没有用

    // while (!CHKBIT(MCASP->SRCTL12, XRDY)) {}
    while (!CHKBIT(MCASP->XSTAT, XDATA)){}
    MCASP->XBUF12 = input_audio_32bit[sample];
    SETBIT(MCASP->XSTAT,XDATA);
    }
    }

    下面是定时器的中断服务等相关程序

    // Timer0 3:4 中断服务 ***************************************************************************
    void MyTimerIsr(void)
    {
    static char Count_coreLED1=0;
    static char Count_coreLED2=0;

    // Timer0 3:4中断周期1mS
    // 核心板LED1 :主循环正常闪烁周期=Timer34中断周期 x PRD_coreLED2 =1mS x (49+1) =50mS
    char PRD_coreLED1=49;
    // 核心板LED2 :主循环正常闪烁周期=Timer34中断周期 x PRD_coreLED2 =1mS x (99+1) =100mS
    char PRD_coreLED2=99;

    // 清除TMR0事件标志 EVTCLR2 -> EC64 (仅写1有效)
    HWREG(0x01800048) =0x00000001;

    // 清除TMR0中断标志 INTCTLSTAT->PRDINTSTAT34(仅写1有效)
    SETBIT(TMR0->INTCTLSTAT,0x00020000u); // 在连续运行模式该位被自动清除

    // 核心板LED1 GP2[0]:主循环正常,按PRD_coreLED1周期闪烁
    if(Count_coreLED1)
    Count_coreLED1-=1;
    else
    {
    Count_coreLED1=PRD_coreLED1;
    LED1_overturn();
    }

    // 核心板LED2 GP2[8]:主循环正常,按PRD_coreLED2周期闪烁
    if(Count_coreLED2)
    Count_coreLED2-=1;
    else
    {
    Count_coreLED2=PRD_coreLED2;
    LED2_overturn();
    }
    }

    // Timer0 3:4中断初始化 ***************************************************************************
    void MyTimerInterruptInit(void)
    {
    // 关联中断号cpuINT和中断服务程序userISR
    IntRegister(7, MyTimerIsr);

    // 关联系统事件SYS_INT_T64P0_TINT34和中断号C674X_MASK_INT7
    IntEventMap(7, 64);

    // 使能 DSP 可屏蔽中断
    IntEnable(7);

    // 使能TMR0的Timer34中断
    SETBIT(TMR0->INTCTLSTAT, PRDINTEN34);
    }

  • 代码运行在哪里?XSTAT.XDATA能不能置1?