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.

TMS320C5535 UART boot后程序执行出现问题

大家好!

最近新作的一个项目,用到了STM32和C5535,工作流程是C5535接收音频codec的i2s数据,对数据进行处理后通过uart发送给stm32.

对于C5535,I2S的数据采用DMA中断来处理,另外使能了uart的接收中断来接收stm32的指令。

为了节约pcb空间,C5535没有外挂spi flash,而是采用stm32的 uart来加载程序。

现在的问题是,C5535在仿真时(自己的5535的pcb加XDS200仿真器)完全能正常工作,但是通过stm32来加载程序后,C5535似乎不能正常工作了(在仿真时在串口可以测到5535发送的数据,但是通过stm32加载后,5535的串口发送没有数据,始终是高电平)。为了进一步验证这个问题,在程序一开始点亮了两颗led,分别在串口发送前后熄灭这两个led,现象是仿真时这两个led确实被点亮后又依次熄灭了,但是通过stm32的uart加载程序后,两个led常亮。

这似乎是说明,程序确实被加载到了5535中(两个led可以被点亮),但是程序却没有被正确执行(led没有被熄灭),但是实在是想不通这是为什么?

个人认为,程序仿真时正常,说明硬件和程序应该都没问题(对吗?),但是通过UART加载后不能正常执行,既然led被点亮起码说明程序被正常加载进去了,但是不能正常执行,是不是UART加载时还需要有特别的设置??

  • 关于上面的问题,现在基本确认是由于程序没有进入到dma中断导致的。无论是c5535的串口发送,还是led的控制,都是在进入dma中断后,置位 了一个标识位,现在5535的串口没有数据发送而且led没有被熄灭说明标识位没有被置位(把led熄灭挪到标识位之外,led可以被熄灭),也就说程序没有进入到dma中断,这是为什么?通过UART加载程序,需要对中断做什么特别处理吗?

  • 我用Ti的例程——“ti\c55_lp\c55_csl_3.06\ccs_v6.x_examples\i2s\CSL_I2S_AudioCodec_DMA”在ti的TMX320C5535 eZDSP上,发现也存在同样的问题。Debug时,在C5535的I2S2_RX和I2S2_TX管脚上都可以可以测到信号,但是将通过hex55.exe转换过的.bin文件通过UartBoot.exe加载到开发板上之后,在C5535的I2S2_TX管脚上测不到信号。

    CSL_I2S_AudioCodec_DMA这个例程:

    void UserAlgorithm(void)
    {
    Uint16 i;
    Uint16 status=0;
    if(!dmaRxFrameCount)
    {
    /* Start left Rx DMA */
    status = DMA_start(dmaLeftRxHandle);
    if (status != CSL_SOK)
    {
    printf("I2S Dma Left Rx Failed!!\n");
    exit(EXIT_FAILURE);
    }


    /* Start right Rx DMA */
    status = DMA_start(dmaRightRxHandle);
    if (status != CSL_SOK)
    {
    printf("I2S Dma Right Rx Failed!!\n");
    exit(EXIT_FAILURE);
    }

    }


    if (dmaRxFrameCount >= 2)
    {
    dmaRxFrameCount=0;
    DMA_stop(dmaLeftRxHandle);
    DMA_stop(dmaRightRxHandle);

    for (i=0; i<I2S_DMA_BUF_LEN; i++)
    {

    i2sDmaWriteBufLeft[i] = i2sDmaReadBufLeft[i];
    i2sDmaWriteBufRight[i] = i2sDmaReadBufRight[i];
    }

    /* --- Insert algorithm here --- */

    }


    if(!dmaTxFrameCount)
    {
    /* Start left Tx DMA */
    status = DMA_start(dmaLeftTxHandle);
    if (status != CSL_SOK)
    {
    printf("I2S Dma Left Tx Failed!!\n");
    exit(EXIT_FAILURE);
    }

    /* Start right Tx DMA */
    status = DMA_start(dmaRightTxHandle);
    if (status != CSL_SOK)
    {
    printf("I2S Dma Right Tx Failed!!\n");
    exit(EXIT_FAILURE);
    }

    }


    /* Clear DMA frame count */
    if(dmaTxFrameCount>=2)
    {
    dmaTxFrameCount = 0;
    DMA_stop(dmaLeftTxHandle);
    DMA_stop(dmaRightTxHandle);
    }

    }

    其中dma中断函数如下:

    interrupt void DmaIsr(void)
    {
    volatile Uint16 ifrValue;

    /* Clear the DMA interrupt */
    ifrValue = CSL_SYSCTRL_REGS->DMAIFR;
    CSL_SYSCTRL_REGS->DMAIFR |= ifrValue;

    /* Check for DMA1 CH0 transfer completion */
    #ifdef INSTANCE0_I2S
    if (ifrValue & 1)
    {
    dmaTxFrameCount++;
    }
    #endif

    #ifdef INSTANCE2_I2S
    if (ifrValue & (1<<4))
    {
    dmaTxFrameCount++;
    }
    #endif


    /* Check for DMA1 CH1 transfer completion */
    #ifdef INSTANCE0_I2S
    if (ifrValue & (1<<1))
    {
    dmaTxFrameCount++;
    }
    #endif

    #ifdef INSTANCE2_I2S
    if (ifrValue & (1<<5))
    {
    dmaTxFrameCount++;
    }
    #endif

    /* Check for DMA1 CH2 transfer completion */
    #ifdef INSTANCE0_I2S
    if (ifrValue & (1<<2))
    {
    dmaRxFrameCount++;
    }
    #endif
    #ifdef INSTANCE2_I2S
    if (ifrValue & (1<<6))
    {
    dmaRxFrameCount++;
    }
    #endif

    /* Check for DMA1 CH3 transfer completion */
    #ifdef INSTANCE0_I2S
    if (ifrValue & (1<<3))
    {
    dmaRxFrameCount++;
    }
    #endif
    #ifdef INSTANCE2_I2S

    if (ifrValue & (1<<7))
    {
    dmaRxFrameCount++;
    }
    #endif

    dmaIntCount++;
    }

    5535的tx管脚没有信号,我认为是5535没有进入到dma中断导致的,也就是说跟我在自己的pcb上遇到的情况一样,5535始终无法进入dma中断!!

    实在找不到原因,希望ti的工作人员能够给予解答!!!

  • 已线下解决,原因如下: