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.

AM5718: SPI传输事件触发EDMA的问题(急)

Part Number: AM5718
Other Parts Discussed in Thread: SYSBIOS, , TMS320C6748

TI的工程师,您好,我之前询问过几个有关SPI传输的问题,但有一些很重要的问题始终没有解决,我看了中英文几乎论坛上所有有关这方面的帖子,也分析了TI提供的例程,甚至也分析了有关这方面的底层的源码,依然没有办法实现SPI传输触发EDMA传输。

我查看了芯片手册有关的寄存器,并且在程序中也看到了相关的配置,但是还是没有找到解决方案。

现阶段的情况:

1、能够进行SPI轮询和中断方式传输,时钟频率为48Mhz。

2、不能使用EDMA传输,而所有寄存器都已正确配置,并且读取到的MCSPI_CHxSTAT寄存器的值为0x28,也就是符合触发EDMA的条件却没有触发。

3、使用的库版本为processor_sdk_rtos_am57xx_06_03_02_08。

4、将SPI_dma.c文件中的事件触发改为手动触发能够进行EDMA传输,但是传输的数据为重复的字节。

5、参考例程MCSPI_BasicExample_Dma_idkAM571x_c66TestProject。

6、无论哪种方式传输,使用示波器测试出当调用MCSPI_transfer后,传输迟迟没有开始,间隔了10-20us后开始传输,在传输结束5-10us后CS才拉高,并且传输时每个字节之间有200ns-500ns的间隔,也就是说传输10个字节时整个过程的时间为30-50us。

目前的问题:

1、SPI传输事件不能触发EDMA的原因?

2、传输过程为何延迟会这么大?

部分测试代码如下:

Fullscreen
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
/*********************************************************************
* (C)2022,
*
* // bsp_spi.c
* //
* // spi
* //
* // V1.0
* //
* // 20220208
*
* 1//
*
*
*
* 2
**********************************************************************/
/* XDCtools */
#include <xdc/std.h>
#include <xdc/cfg/global.h>
XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX

cfg文件如下:

Fullscreen
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
//BWC, add Program var
/* root of the configuration object model */
var Program = xdc.useModule('xdc.cfg.Program');
/* ================ General configuration ================ */
var Memory = xdc.useModule('xdc.runtime.Memory');
var HeapMem = xdc.useModule('ti.sysbios.heaps.HeapMem');
var HeapBuf = xdc.useModule('ti.sysbios.heaps.HeapBuf');
var Log = xdc.useModule('xdc.runtime.Log');
var Task = xdc.useModule('ti.sysbios.knl.Task');
var Semaphore = xdc.useModule('ti.sysbios.knl.Semaphore');
var Hwi = xdc.useModule('ti.sysbios.family.c64p.Hwi');
var ECM = xdc.useModule('ti.sysbios.family.c64p.EventCombiner');
var System = xdc.useModule('xdc.runtime.System');
SysStd = xdc.useModule('xdc.runtime.SysStd');
var IntXbar = xdc.useModule('ti.sysbios.family.shared.vayu.IntXbar');
var halCache = xdc.useModule('ti.sysbios.hal.Cache');
var Idle = xdc.useModule('ti.sysbios.knl.Idle');
var Deh = xdc.useModule('ti.deh.Deh');
var Timer = xdc.useModule('ti.sysbios.hal.Timer');
XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX

部分测试结果如下:

期待您的回复,谢谢!

  • 请问是自己的板子还是EVM板?SPI+EDMA内部自环模式是否能成功?先确认EDMA的配置没有问题。

  • 感谢回复,使用的自己的板子,我将SPI1D0连接的SPI1D1,配置为SPI_Master模式进行传输无法触发EDMA,但是我不使用SPI时单独测试EDMA使用手动触发能够在两块内存之间进行EDMA传输。

  • 您好,我在查看芯片用户手册时注意到AM5718的SPI并没有内部自环模式,而TMS320C6748的SPI有loopback自环模式,好像AM5718对SPI裁剪了些什么。

  • 抱歉,确实没有内部自环。

    请问要传输的数据是放在哪里的?

  • 感谢回复,要传输的数据是一个放在全局数组里面,并且设置32字节对齐和128字节对齐都测试过

  • 您好,请问有任何进展吗?我再次使用CSL的方式SPI事件也无法触发EDMA。

    以下是CSL方式的部分程序:

    Fullscreen
    1
    2
    3
    4
    5
    6
    7
    8
    9
    10
    11
    12
    13
    14
    15
    16
    17
    18
    19
    20
    21
    /*
    * bsp_spi_csl.c
    *
    * Created on: 202234
    * Author:
    */
    /* ========================================================================== */
    /* Include Files */
    /* ========================================================================== */
    #include "stdint.h"
    #include <stdio.h>
    #include <ti/csl/csl_mcspi.h>
    #include <ti/csl/csl_i2c.h>
    #include <ti/csl/example/utils/uart_console/inc/uartConfig.h>
    #include <ti/csl/csl_types.h>
    #include <ti/csl/soc.h>
    #include <ti/csl/hw_types.h>
    #include <ti/csl/csl_edma.h>
    #include <ti/csl/arch/csl_arch.h>
    #include <ti/csl/example/utils/common/inc/app_utils.h>
    XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX

  • 感谢回复,要传输的数据是一个放在全局数组里面,并且设置32字节对齐和128字节对齐都测试过

    数据是放在片上RAM还是片外DDR里的?

    EDMA还是能传输数据的,只是有延时,我觉得基本配置是正确的。

  • 感谢回复,我在调试时看到rxbuff的地址是0x951827c0,tx的地址是0x95182cc0。

    rsc_table_vayu_dsp如下:

    Fullscreen
    1
    2
    3
    4
    5
    6
    7
    8
    9
    10
    11
    12
    13
    14
    15
    16
    17
    18
    19
    20
    21
    /*
    * Copyright (c) 2017, Texas Instruments Incorporated
    * All rights reserved.
    *
    * Redistribution and use in source and binary forms, with or without
    * modification, are permitted provided that the following conditions
    * are met:
    *
    * * Redistributions of source code must retain the above copyright
    * notice, this list of conditions and the following disclaimer.
    *
    * * Redistributions in binary form must reproduce the above copyright
    * notice, this list of conditions and the following disclaimer in the
    * documentation and/or other materials provided with the distribution.
    *
    * * Neither the name of Texas Instruments Incorporated nor the names of
    * its contributors may be used to endorse or promote products derived
    * from this software without specific prior written permission.
    *
    * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
    * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
    XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX

    config.bld如下:

    Fullscreen
    1
    2
    3
    4
    5
    6
    7
    8
    9
    10
    11
    12
    13
    14
    15
    16
    17
    18
    19
    20
    21
    /*
    * Copyright (c) 2013-2015, Texas Instruments Incorporated
    * All rights reserved.
    *
    * Redistribution and use in source and binary forms, with or without
    * modification, are permitted provided that the following conditions
    * are met:
    *
    * * Redistributions of source code must retain the above copyright
    * notice, this list of conditions and the following disclaimer.
    *
    * * Redistributions in binary form must reproduce the above copyright
    * notice, this list of conditions and the following disclaimer in the
    * documentation and/or other materials provided with the distribution.
    *
    * * Neither the name of Texas Instruments Incorporated nor the names of
    * its contributors may be used to endorse or promote products derived
    * from this software without specific prior written permission.
    *
    * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
    * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
    XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX

    linker.cmd如下:

    Fullscreen
    1
    2
    3
    4
    5
    6
    7
    8
    9
    10
    11
    12
    13
    14
    15
    16
    17
    18
    19
    20
    21
    /*
    * Do not modify this file; it is automatically generated from the template
    * linkcmd.xdt in the ti.targets.elf package and will be overwritten.
    */
    /*
    * put '"'s around paths because, without this, the linker
    * considers '-' as minus operator, not a file name character.
    */
    -l"R:\tmpdesktop\A390_C6000_Project\Debug\configPkg\package\cfg\A390_pe66.oe66"
    -l"R:\tmpdesktop\A390_C6000_Project\TiConfig\source\src\ipc\ipc.ae66"
    -l"D:\ti\processor_sdk_rtos_am57xx_06_03_02_08\ipc_3_50_04_08\packages\ti\pm\lib\release\ti.pm_null.ae66"
    -l"D:\ti\processor_sdk_rtos_am57xx_06_03_02_08\edma3_lld_2_12_05_30E\packages\ti\sdo\edma3\drv\sample\lib\tda2xx-evm\66\release\edma3_lld_drv_sample.ae66"
    -l"R:\tmpdesktop\A390_C6000_Project\TiConfig\source\src\utils\utils.ae66"
    -l"D:\ti\processor_sdk_rtos_am57xx_06_03_02_08\pdk_am57xx_1_0_18\packages\ti\board\lib\idkAM571x\c66\release\ti.board.ae66"
    -l"D:\ti\processor_sdk_rtos_am57xx_06_03_02_08\pdk_am57xx_1_0_18\packages\ti\drv\i2c\lib\c66\release\ti.drv.i2c.ae66"
    -l"D:\ti\processor_sdk_rtos_am57xx_06_03_02_08\pdk_am57xx_1_0_18\packages\ti\drv\uart\lib\c66\release\ti.drv.uart.ae66"
    -l"D:\ti\processor_sdk_rtos_am57xx_06_03_02_08\pdk_am57xx_1_0_18\packages\ti\drv\gpio\lib\am571x\c66\release\ti.drv.gpio.ae66"
    -l"D:\ti\processor_sdk_rtos_am57xx_06_03_02_08\pdk_am57xx_1_0_18\packages\ti\osal\lib\tirtos\c66\release\ti.osal.ae66"
    XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX

    我不太能确认是在片上RAM还是DDR,但看起来应该是在片上RAM区间。

  • 您好,您用我的测试程序运行EDMA能传输数据吗?传输延迟也是很大吗?

    另外,我重新配置了DSP核的内存结构,使用了L2SRAM,因为我看到L2SRAM直接连接的EDMA,因此,我将数据放在L2SRAM中,但程序无法运行,运行结果如下:

    cat /sys/kernel/debug/remoteproc/remoteproc2/trace0

    cat: can't open '/sys/kernel/debug/remoteproc/remoteproc2/trace0': No such file or directory

    config.bld配置如下:

    Fullscreen
    1
    2
    3
    4
    5
    6
    7
    8
    9
    10
    11
    12
    13
    14
    15
    16
    17
    18
    19
    20
    21
    /*
    * Copyright (c) 2013-2015, Texas Instruments Incorporated
    * All rights reserved.
    *
    * Redistribution and use in source and binary forms, with or without
    * modification, are permitted provided that the following conditions
    * are met:
    *
    * * Redistributions of source code must retain the above copyright
    * notice, this list of conditions and the following disclaimer.
    *
    * * Redistributions in binary form must reproduce the above copyright
    * notice, this list of conditions and the following disclaimer in the
    * documentation and/or other materials provided with the distribution.
    *
    * * Neither the name of Texas Instruments Incorporated nor the names of
    * its contributors may be used to endorse or promote products derived
    * from this software without specific prior written permission.
    *
    * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
    * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
    XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX

    rsc_table_vayu_dsp增加如下行:

    #define L2_RAM_BASE 0x40808000
    #define DSP_L2_RAM_BASE 0x40808000
    #define DSP_L2_RAM_SIZE 0x40000

    {
    TYPE_DEVMEM,
    L2_RAM_BASE, DSP_L2_RAM_BASE,
    DSP_L2_RAM_SIZE, 0, 0, "DSP_L2_RAM_BASE",
    },

    cfg文件增加如下行:

    Program.sectMap[".l2sram"] = "DSPL2SRAM";

    缓冲区更改如下:

    /*
    * 变量作用:MCSPI发送数据缓冲区
    * 变量范围:无
    * 访问说明:访问函数:xgMcspiTransfer,访问方法:赋值拷贝
    */

    #pragma DATA_SECTION (s_acTxBuff,".l2sram")
    #pragma DATA_ALIGN (s_acTxBuff,128)
    char s_acTxBuff[MCSPI_DATA_COUNT ] = { "123456789" };

    /*
    * 变量作用:MCSPI接收数据缓冲区
    * 变量范围:无
    * 访问说明:访问函数 xgMcspiTransfer,访问方法:赋值拷贝
    */
    #pragma DATA_SECTION (s_acRxBuff,".l2sram")
    #pragma DATA_ALIGN (s_acRxBuff,128)
    char s_acRxBuff[MCSPI_DATA_COUNT ] = { 0 };

    我不确定是不是内存区域的问题,但我也正在尝试各种办法,如果您有任何参考意见都请告诉我,感谢!

  • 抱歉,我手头没有板子。您可以到e2e英文论坛上问一下产品线工程师。
    https://e2e.ti.com/support/processors-group/

    0x951827c0这块地址是DDR3,可以尝试打开cache,看速度是否能加快。

  • 感谢回复,我没有e2e论坛发帖的权限,您能把我的情况发给产品线工程师吗?

    我目前是没有触发EDMA传输,还在查找问题在哪里,而我使用L2SRAM作为存储区依然没有成功。

  • 您可以用公司或者学校邮箱注册登录英文e2e。

    把您的问题转到e2e了,请关注下面帖子的回复。
    https://e2e.ti.com/support/processors-group/processors/f/processors-forum/1082545/am5718-spi-transfer-delay-when-using-edma

  • 嗯嗯  感谢!我无法使用公司邮箱,如果回复了麻烦您帮我转发一下。

  • 好的,不客气~

  • 您好,我想到了一个可能性,由于是AM5718的DSP核,而不是单独的DSP,因此没有调用Board_init(),否则A15无法正常运行,所以只是初始化了SPI时钟和引脚模式,这有可能导致EDMA无法触发吗?EDMA也需要硬件初始化吗?

    初始化SPI时钟和引脚程序如下:

    void PinmuxMCSPIConfig()
    {
        /* Power on SPI1*/
        HW_WR_REG32(0x4a0097f0, 0x02);
        while (HW_RD_REG32(0x4a0097f0) != 0x02U)

        {

        ;

        }

        /* SPI1_SCLK */
        HW_WR_REG32((CSL_MPU_CORE_PAD_IO_REGISTERS_REGS + CTRL_CORE_PAD_SPI1_SCLK),0x000C0000);
        /* SPI1_D0 */
        HW_WR_REG32((CSL_MPU_CORE_PAD_IO_REGISTERS_REGS + CTRL_CORE_PAD_SPI1_D0),0x000C0000);
        /* SPI1_D1 */
        HW_WR_REG32((CSL_MPU_CORE_PAD_IO_REGISTERS_REGS + CTRL_CORE_PAD_SPI1_D1),0x000C0000);
        /* SPI1_CS0 */
        HW_WR_REG32((CSL_MPU_CORE_PAD_IO_REGISTERS_REGS + CTRL_CORE_PAD_SPI1_CS0),0x00060000);
    }

  • 您不是可以通过EDMA传输内部数据的吗?而且SPI+EDMA能传输,只是延时的问题,说明EDMA还是工作了。

  • 感谢回复,我只能通过手动触发EDMA传输SPI的数据,但无法使用事件触发EDMA,这样说也对,EDMA确实工作了,只是不能通过事件触发以及延时较大。

    最新进展:测试出的延迟主要来自于开关SPI的EDMA传输通道。

  • 请问是怎么得出整个结论的?

  • 感谢关注问题,我通过手动触发EDMA,但是我把回调函数中的关闭通道屏蔽,发现传输的波形很连续(虽然数据是错的),但是我取消屏蔽关闭通道时,波形就不再连续了。

    虽然手动能够传输数据,但是数据始终是错误的,最多只能重复传输4个字节的内容,也就是SPI配置的传输字长32bit,其实就是将TX寄存器32bit的数据一直重复传输出去,接收方收到的始终是这4个字节。

    我在尝试修改底层的SPI_DMA.c的代码,希望能实现手动快速且正确地传输数据(事件实在想不到办法触发EDMA了)。

  • 非常感谢您的关注,我也会持续关注。

  • 您好,在我换方案使用mcasp来替代SPI的时候发现了一个问题,我没有配置SPI的资源表和EDMA的资源表。

    解决方案如下帖子:

    https://e2echina.ti.com/support/processors/f/processors-forum/218129/am5718-mcasp

    https://e2echina.ti.com/support/processors/f/processors-forum/218724/am5718-dsp-mcasp-edma

    再次感谢!

  • 非常感谢告知解决方法!

x 出现错误。请重试或与管理员联系。