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.

TDA4VH-Q1: How does the MCAL SPI module use DMA?

Part Number: TDA4VH-Q1
Other Parts Discussed in Thread: SYSCONFIG, TDA4VH

Tool/software:

1. I configured MCU_MCSPI0, and I don't know how to check what the SpiDmaTxChIntrNum and SpiDmaRxChIntrNum should be.

2. Is there a demo for configuring SPI with DMA in MCAL?

  • TDA4 MCU1_0中使用MCU_MCSPI0:

    SCLK:G38

    CS:F37

    D0:H36

    D1:J38

    想要配置为DMA模式,MCU_MCSPI0用到的DMA的中断号没有查到,这个应该在哪里查看,怎么对应?

  • Hello,

    We can use the same example in MCUSW with DMA enabled in configurator. 

    SpiDmaTxChIntrNum and SpiDmaRxChIntrNum should be.

    which core you are using SPI+DMA ? If it is MCU1_0 then you can use 79 ,80 or 80 ,81 if you are not using DMA elsewhere in the system.

    Regards

    Tarun Mukesh

  • The TDA4 MCU island was configured as the Master, and the DMA mode was enabled. It was found that some data was not sent out. Figure 1 shows the data captured by the logic analyzer, and Figure 2 is the actual data displayed by Laubach.

  • The initialization of SPI and UDMA is as shown in the following figure.

    The SPI configuration is as follows

  • Hello,

    There has been couple of bug fixes done on SDK 11.1 for SPI DMA related issues regarding data transfer for different bus widths. I would you request to see the delta between SDK 11.1 and what ever SDK version you are on.

    Especially udma_init is removed from driver and placed in application . Are you using DMA else where in the system ?

    COuld you share me the core register dump of SPI registers  please ?

    Regards

    Tarun MUkesh

  • hello

    Only this part requires manual invocation of UDMA initialization.

    the SDK version we are using is 11_00_00_06

    spi pin :

    spi  registers:

    [0x40300000] CFG_HL_REV : 0x40301A0B
    [0x40300004] CFG_HL_HWINFO : 0x00000009
    [0x40300010] CFG_HL_SYSCONFIG : 0x00000004

    [0x40300100] CFG_REVISION : 0x0000002B
    [0x40300110] CFG_SYSCONFIG : 0x00000308
    [0x40300114] CFG_SYSSTATUS : 0x00000001
    [0x40300118] CFG_IRQSTATUS : 0x00000000
    [0x4030011C] CFG_IRQENABLE : 0x00000000
    [0x40300120] CFG_WAKEUPENABLE : 0x00000000
    [0x40300124] CFG_SYST : 0x00000000
    [0x40300128] CFG_MODULCTRL : 0x00000003
    [0x4030012C] CFG_CH0CONF : 0x200103E0
    [0x40300130] CFG_CH0STAT : 0x00000006
    [0x40300134] CFG_CH0CTRL : 0x00000000
    [0x40300138] CFG_TX0 : 0x000000FF
    [0x4030013C] CFG_RX0 : 0xFCFDFEFF
    [0x40300140] CFG_CH1CONF : 0x00060000
    [0x40300144] CFG_CH1STAT : 0x00000000
    [0x40300148] CFG_CH1CTRL : 0x00000000
    [0x4030014C] CFG_TX1 : 0x00000000
    [0x40300150] CFG_RX1 : 0x00000000
    [0x40300154] CFG_CH2CONF : 0x00060000
    [0x40300158] CFG_CH2STAT : 0x00000000
    [0x4030015C] CFG_CH2CTRL : 0x00000000
    [0x40300160] CFG_TX2 : 0x00000000
    [0x40300164] CFG_RX2 : 0x00000000
    [0x40300168] CFG_CH3CONF : 0x00060000
    [0x4030016C] CFG_CH3STAT : 0x00000000
    [0x40300170] CFG_CH3CTRL : 0x00000000
    [0x40300174] CFG_TX3 : 0x00000000
    [0x40300178] CFG_RX3 : 0x00000000
    [0x4030017C] CFG_XFERLEVEL : 0x00000000
    [0x40300180] CFG_DAFTX : 0x00000000
    [0x403001A0] CFG_DAFRX : 0x00000000

  • Hello,

    Let me go through the registers. 

    Figure 2 is the actual data displayed by Laubach.

    You are sending some data (218, 07 etc...) and expecting same data to be received as per lauterbach log data . you are doing an external loop back test ?

    If not then what is the slave here ?

    and also as per logic analyser i don't see data on RX(MISO) pin so is slave not sending data ?

    Regards

    Tarun Mukesh

  • and also 

    • Are you doing the MCSPI test only in the system?
      • If yes, then please try SDK11.1 code for SPI + DMA.
      • If no, please help to check whether it is possible to simplify to run this example only.
    • Did you ever do same test without enable DMA? 

    Regards

    Tarun 

  • The data sent by the master and the slave are the same.

    Miso is as follows:

  • Besides SPI, there're also I2C, UART, and OSPI and so on.

    There is only SPI without testing. I'll give it a try.

  • Hello,

    Miso is as follows:

    Your MISO is 0 right for the initial time .

    what is slave in your system ? I don't think your slave is sending data initially for some time.

    Regards

    Tarun Mukesh

  • The SPI configuration of TDA4 MCU ISLAND is set as master. There are problems with the master's transmission, as shown in the above figure, the red box indicates the issue. the data sent and received by the master is the same, and there is no problem when the master receives the data.

  • Hello,

    D0 is reception which means it is MISO

    D1 is transmission which means it is MOSI

    But here,

    D0 is connected as MOSI and D1 is connected as MISO.

    To debug this , enable only SPI in the system without any one influencing the pins of transmission 

    Besides SPI, there're also I2C, UART, and OSPI and so on.

    There is only SPI without testing. I'll give it a try.

    and when you are sending the first message (Ex: 218 ,7 ...) see that is written in the register

    [0x40300138] CFG_TX0 : 

    \

    Regards

    Tarun Mukesh

  • https://e2e.ti.com/cfs-file/__key/communityserver-discussions-components-files/791/mcspi_5F00_tx_5F00_dma.tar.xzHi Tarun:

    We has meet with customer about this issue. Some question need you help us provide some demo/suggest.

    1. At TDA4VH does we has MCU domain control MCU_SPIx master DMA loopback test case? 

       we has modified TDA4Entry main MCU R5F control main McSPI0 Loopback demo at RTOS11.1 RDK, but TDA4VH we do not successful enable those examples. customer want based on our pure MCU domain DMA SPI loopback demo merge to their project.

    2. Based on last several week debug, customer think it relationship with MCU Domain SPI UDMA conflict, Do you has same suggest about analyze TDA4VH OS + MCU control SPI DMA debug method for customer?

    Below is our TDA4Ventry main MCU control SPI DMA_LOOPBACK example for you refences.

    Best Regards!

    Han Tao

  • Hello,

    I don't understand why you are taking TDA4entry examples .

    we already have MCU SPI0 with DMA example in path mcusw/mcal_drv/mcal/examples/Spi/mcspi_app in TDA4VH

    You need to enable the DMA flag and give interrupt numbers 79 and 80 it will work fine.

    We can use the same example in MCUSW with DMA enabled in confi

    I have conveyed this before as well, why are you not considering MCAL example ?

    Regards

    Tarun Mukesh

  • 1.There is no initialization part for DMA in this demo.

    2.We tested the SPI without DMA for over two days and found no issues.

    3.The MCU domain only utilized VTM, PMIC, SPI and UART. In this system, using SPI to enable DMA caused a data transmission problem.

  • Hello,

    There is DMA intialization, you can see line 159 . We need to turn on "SPI_DMA_ENABLE" flag. 

    Regards

    Tarun Mukesh

  • Hi Tarun:

    Sorry make you confuse. Because do not has TDA4VH EVM board, we tried it at TDA4Entry.

    Thanks for provide DMA demo enable method and we will try it with customer together.

    Best Regards!

    Han Tao

  • Hello,

    Because do not has TDA4VH EVM board, we tried it at TDA4Entry

    Ok. On Entry device we don't have support for DMA since it is not PDK but MCU+SDK based.

    Please try with any other jacinto board but not entry.

    Regards

    Tarun Mukesh

  •  Mcal demo DMA initialization failed

  • Hello,

    Please share me your Spi_PBcfg.c file of the demo.

    You need to enable the DMA flag and give interrupt numbers 79 and 80 it will work fine.

    Have you done this changes ?

    Regards

    Tarun Mukesh

  • /*
    *
    * Copyright (c) 2024 Texas Instruments Incorporated
    *
    * All rights reserved not granted herein.
    *
    * Limited License.
    *
    * Texas Instruments Incorporated grants a world-wide, royalty-free, non-exclusive
    * license under copyrights and patents it now or hereafter owns or controls to make,
    * have made, use, import, offer to sell and sell ("Utilize") this software subject to the
    * terms herein.  With respect to the foregoing patent license, such license is granted
    * solely to the extent that any such patent is necessary to Utilize the software alone.
    * The patent license shall not apply to any combinations which include this software,
    * other than combinations with devices manufactured by or for TI ("TI Devices").
    * No hardware patent is licensed hereunder.
    *
    * Redistributions must preserve existing copyright notices and reproduce this license
    * (including the above copyright notice and the disclaimer and (if applicable) source
    * code license limitations below) in the documentation and/or other materials provided
    * with the distribution
    *
    * Redistribution and use in binary form, without modification, are permitted provided
    * that the following conditions are met:
    *
    * *       No reverse engineering, decompilation, or disassembly of this software is
    * permitted with respect to any software provided in binary form.
    *
    * *       any redistribution and use are licensed by TI for use only with TI Devices.
    *
    * *       Nothing shall obligate TI to provide you with source code for the software
    * licensed and provided to you in object code.
    *
    * If software source code is provided to you, modification and redistribution of the
    * source code are permitted provided that the following conditions are met:
    *
    * *       any redistribution and use of the source code, including any resulting derivative
    * works, are licensed by TI for use only with TI Devices.
    *
    * *       any redistribution and use of any object code compiled from the source code
    * and any resulting derivative works, are licensed by TI for use only with TI Devices.
    *
    * Neither the name of Texas Instruments Incorporated nor the names of its suppliers
    *
    * may be used to endorse or promote products derived from this software without
    * specific prior written permission.
    *
    * DISCLAIMER.
    *
    * THIS SOFTWARE IS PROVIDED BY TI AND TI'S LICENSORS "AS IS" AND ANY EXPRESS
    * OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
    * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
    * IN NO EVENT SHALL TI AND TI'S LICENSORS BE LIABLE FOR ANY DIRECT, INDIRECT,
    * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
    * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
    * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
    * OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE
    * OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED
    * OF THE POSSIBILITY OF SUCH DAMAGE.
    *
    */
    
    /**
     *  \file     Spi_PBcfg.c
     *
     *  \brief    This file contains generated post build configuration file
     *            for SPI MCAL driver
     */
    
      /*****************************************************************************
        Project         : j784s4_spi
        Date            : 2024-10-22 14:16:21
        SW Ver          : 9.0.1
        Module Rele Ver : AUTOSAR 4.3.1 0
    	
        This file is generated by EB Tresos
        Do not modify this file, otherwise the software may behave in unexpected way
     ******************************************************************************/
    
    /*******************************************************************************
     *  INCLUDES
     ******************************************************************************/
    #include "Spi.h"
    #include "Spi_Irq.h"
    
    /*
     * Design: MCAL-6472
     */
    
    /*******************************************************************************
     *  VERSION CHECK
     ******************************************************************************/
    #if ((SPI_SW_MAJOR_VERSION != (9U)) || (SPI_SW_MINOR_VERSION != (2U)))
      #error "Version numbers of Spi_PBcfg.c and Spi.h are inconsistent!"
    #endif
    /*******************************************************************************
     *  LOCAL CONSTANT MACROS
     ******************************************************************************/
    
    /*******************************************************************************
     *  LOCAL FUNCTION MACROS
     ******************************************************************************/
    
    /*******************************************************************************
     *  LOCAL DATA TYPES AND STRUCTURES
     ******************************************************************************/
    
    /*******************************************************************************
     *  LOCAL DATA PROTOTYPES
     ******************************************************************************/
    
    /*******************************************************************************
     *  GLOBAL DATA
     ******************************************************************************/
    #define  SPI_START_SEC_CONFIG_DATA
    #include "Spi_MemMap.h"
    /* generation of runtime configuration       */
    
    #ifdef __cplusplus
    extern "C" {
    #endif
    
    
    
    
    extern void SpiApp_McuMcspiJob0EndNotification(void);
    
    extern void SpiApp_McuMcspiSeq0EndNotification(void);
    
    CONST(struct Spi_ConfigType_s, SPI_CONFIG_DATA) SpiDriver =
    {
        .maxChannels = 1U,
        .maxJobs = 1U,
        .maxSeq  = 1U,
        .maxHwUnit = 1U,
        .maxExtDevCfg = 1U,
        .udmaInstId  = (uint32)UDMA_INST_ID_MCU_0,
        .cacheWbInv = (Spi_CacheWbInv)SpiApp_wbInvCache,
        .cacheWb = (Spi_CacheWb)SpiApp_wbCache,
        .cacheInv = (Spi_CacheInv)SpiApp_invCache,
        .channelCfg =
        {
                [0] =
                {
                    .channelBufType = SPI_EB,
                    .dataWidth = 32U,
                    .defaultTxData = 0U,
                    .maxBufLength = 10000U,
                    .transferType = SPI_MSB,
                },
            },
        .jobCfg =
        {
                [0] =
                {
                    .jobPriority = SPI_JOB_PRIORITY_0,
                    .hwUnitId = SPI_UNIT_MCU_MCSPI0,
                    .Spi_JobEndNotification = SpiApp_McuMcspiJob0EndNotification,
                    .channelPerJob = 1U,
                    .channelList =
                    {
                        [0] = 0U,
                    },
                },
            },
        .seqCfg =
        {
                [0] =
                {
                    .seqInterruptible = (uint8) TRUE,
                    .Spi_SequenceEndNotification = SpiApp_McuMcspiSeq0EndNotification,
                    .jobPerSeq = 1U,
                    .jobList =
                    {
                        0U,
                    },
                },
            },
        .hwUnitCfg =
        {
                [0] =
                {
                    .hwUnitId = SPI_UNIT_MCU_MCSPI0,
                    .enabledmaMode = (boolean)TRUE,
                    .dmaTxChIntrNum = 80,
                    .dmaRxChIntrNum = 81,
                },
                [1] =
                {
                    .hwUnitId = SPI_UNIT_MCU_MCSPI1,
                    .enabledmaMode = (boolean)FALSE,
                    .dmaTxChIntrNum = 0,
                    .dmaRxChIntrNum = 0,
                },
                [2] =
                {
                    .hwUnitId = SPI_UNIT_MCU_MCSPI2,
                    .enabledmaMode = (boolean)FALSE,
                    .dmaTxChIntrNum = 0,
                    .dmaRxChIntrNum = 0,
                },
                [3] =
                {
                    .hwUnitId = SPI_UNIT_MCSPI0,
                    .enabledmaMode = (boolean)FALSE,
                    .dmaTxChIntrNum = 0,
                    .dmaRxChIntrNum = 0,
                },
                [4] =
                {
                    .hwUnitId = SPI_UNIT_MCSPI1,
                    .enabledmaMode = (boolean)FALSE,
                    .dmaTxChIntrNum = 0,
                    .dmaRxChIntrNum = 0,
                },
                [5] =
                {
                    .hwUnitId = SPI_UNIT_MCSPI2,
                    .enabledmaMode = (boolean)FALSE,
                    .dmaTxChIntrNum = 0,
                    .dmaRxChIntrNum = 0,
                },
                [6] =
                {
                    .hwUnitId = SPI_UNIT_MCSPI3,
                    .enabledmaMode = (boolean)FALSE,
                    .dmaTxChIntrNum = 0,
                    .dmaRxChIntrNum = 0,
                },
                [7] =
                {
                    .hwUnitId = SPI_UNIT_MCSPI4,
                    .enabledmaMode = (boolean)FALSE,
                    .dmaTxChIntrNum = 0,
                    .dmaRxChIntrNum = 0,
                },
            },
        .extDevCfg =
        {
                [0] =
                {
            .mcspi =
                    {
                        .csEnable = (uint16) TRUE,
                        .csMode   = SPI_CONTINUOUS,
                        .csPolarity = SPI_HIGH,
                        .csIdleTime = SPI_DATADELAY_0,
                        .clkDivider = 0U,
                        .clkMode = SPI_CLK_MODE_0,
                        .txRxMode     = SPI_TX_RX_MODE_BOTH,
                        .startBitEnable =  (uint16) FALSE,
                        .startBitLevel  = SPI_LOW,
                        .receptionLineEnable  = DATA_LINE_1_RECEPTION,
                        .transmissionLineEnable  = DATA_LINE_1_TRANSMISSION,
                    },
                },
                [1] =
                {
            .mcspi =
                    {
                        .csEnable = (uint16) TRUE,
                        .csMode   = SPI_CONTINUOUS,
                        .csPolarity = SPI_HIGH,
                        .csIdleTime = SPI_DATADELAY_0,
                        .clkDivider = 0U,
                        .clkMode = SPI_CLK_MODE_0,
                        .txRxMode     = SPI_TX_RX_MODE_BOTH,
                        .startBitEnable =  (uint16) FALSE,
                        .startBitLevel  = SPI_LOW,
                        .receptionLineEnable  = DATA_LINE_0_RECEPTION,
                        .transmissionLineEnable  = DATA_LINE_1_TRANSMISSION,
                    },
                },
                [2] =
                {
            .mcspi =
                    {
                        .csEnable = (uint16) TRUE,
                        .csMode   = SPI_CONTINUOUS,
                        .csPolarity = SPI_HIGH,
                        .csIdleTime = SPI_DATADELAY_0,
                        .clkDivider = 0U,
                        .clkMode = SPI_CLK_MODE_0,
                        .txRxMode     = SPI_TX_RX_MODE_BOTH,
                        .startBitEnable =  (uint16) FALSE,
                        .startBitLevel  = SPI_LOW,
                        .receptionLineEnable  = DATA_LINE_0_RECEPTION,
                        .transmissionLineEnable  = DATA_LINE_1_TRANSMISSION,
                    },
                },
                [3] =
                {
            .mcspi =
                    {
                        .csEnable = (uint16) TRUE,
                        .csMode   = SPI_CONTINUOUS,
                        .csPolarity = SPI_HIGH,
                        .csIdleTime = SPI_DATADELAY_0,
                        .clkDivider = 0U,
                        .clkMode = SPI_CLK_MODE_0,
                        .txRxMode     = SPI_TX_RX_MODE_BOTH,
                        .startBitEnable =  (uint16) FALSE,
                        .startBitLevel  = SPI_LOW,
                        .receptionLineEnable  = DATA_LINE_0_RECEPTION,
                        .transmissionLineEnable  = DATA_LINE_1_TRANSMISSION,
                    },
                },
                [4] =
                {
            .mcspi =
                    {
                        .csEnable = (uint16) TRUE,
                        .csMode   = SPI_CONTINUOUS,
                        .csPolarity = SPI_HIGH,
                        .csIdleTime = SPI_DATADELAY_0,
                        .clkDivider = 0U,
                        .clkMode = SPI_CLK_MODE_0,
                        .txRxMode     = SPI_TX_RX_MODE_BOTH,
                        .startBitEnable =  (uint16) FALSE,
                        .startBitLevel  = SPI_LOW,
                        .receptionLineEnable  = DATA_LINE_0_RECEPTION,
                        .transmissionLineEnable  = DATA_LINE_1_TRANSMISSION,
                    },
                },
                [5] =
                {
            .mcspi =
                    {
                        .csEnable = (uint16) TRUE,
                        .csMode   = SPI_CONTINUOUS,
                        .csPolarity = SPI_HIGH,
                        .csIdleTime = SPI_DATADELAY_0,
                        .clkDivider = 0U,
                        .clkMode = SPI_CLK_MODE_0,
                        .txRxMode     = SPI_TX_RX_MODE_BOTH,
                        .startBitEnable =  (uint16) FALSE,
                        .startBitLevel  = SPI_LOW,
                        .receptionLineEnable  = DATA_LINE_0_RECEPTION,
                        .transmissionLineEnable  = DATA_LINE_1_TRANSMISSION,
                    },
                },
                [6] =
                {
            .mcspi =
                    {
                        .csEnable = (uint16) TRUE,
                        .csMode   = SPI_CONTINUOUS,
                        .csPolarity = SPI_HIGH,
                        .csIdleTime = SPI_DATADELAY_0,
                        .clkDivider = 0U,
                        .clkMode = SPI_CLK_MODE_0,
                        .txRxMode     = SPI_TX_RX_MODE_BOTH,
                        .startBitEnable =  (uint16) FALSE,
                        .startBitLevel  = SPI_LOW,
                        .receptionLineEnable  = DATA_LINE_0_RECEPTION,
                        .transmissionLineEnable  = DATA_LINE_1_TRANSMISSION,
                    },
                },
                [7] =
                {
            .mcspi =
                    {
                        .csEnable = (uint16) TRUE,
                        .csMode   = SPI_CONTINUOUS,
                        .csPolarity = SPI_HIGH,
                        .csIdleTime = SPI_DATADELAY_0,
                        .clkDivider = 0U,
                        .clkMode = SPI_CLK_MODE_0,
                        .txRxMode     = SPI_TX_RX_MODE_BOTH,
                        .startBitEnable =  (uint16) TRUE,
                        .startBitLevel  = SPI_LOW,
                        .receptionLineEnable  = DATA_LINE_0_RECEPTION,
                        .transmissionLineEnable  = DATA_LINE_1_TRANSMISSION,
                    },
                },
            },
    };
    
    #ifdef __cplusplus
    }
    #endif
    
    #define  SPI_STOP_SEC_CONFIG_DATA
    #include "Spi_MemMap.h"
    
    #define  SPI_START_SEC_ISR_CODE
    #include "Spi_MemMap.h"
    /**
     *  \brief SPI Hwunit ISR
     */
    /** \brief SPI MCU_MCSPI0 ISR */
    FUNC(void, SPI_CODE_FAST) Spi_IrqUnitMcuMcspi0TxRx(void)
    {
        Spi_IntISR_McuMcspiTxRx(SPI_UNIT_MCU_MCSPI0);
    }
    /** \brief SPI MCU_MCSPI1 ISR */
    FUNC(void, SPI_CODE_FAST) Spi_IrqUnitMcuMcspi1TxRx(void)
    {
        Spi_IntISR_McuMcspiTxRx(SPI_UNIT_MCU_MCSPI1);
    }
    /** \brief SPI MCU_MCSPI2 ISR */
    FUNC(void, SPI_CODE_FAST) Spi_IrqUnitMcuMcspi2TxRx(void)
    {
        Spi_IntISR_McuMcspiTxRx(SPI_UNIT_MCU_MCSPI2);
    }
    /** \brief SPI MCSPI0 ISR */
    FUNC(void, SPI_CODE_FAST) Spi_IrqUnitMcspi0TxRx(void)
    {
        Spi_IntISR_McuMcspiTxRx(SPI_UNIT_MCSPI0);
    }
    /** \brief SPI MCSPI1 ISR */
    FUNC(void, SPI_CODE_FAST) Spi_IrqUnitMcspi1TxRx(void)
    {
        Spi_IntISR_McuMcspiTxRx(SPI_UNIT_MCSPI1);
    }
    /** \brief SPI MCSPI2 ISR */
    FUNC(void, SPI_CODE_FAST) Spi_IrqUnitMcspi2TxRx(void)
    {
        Spi_IntISR_McuMcspiTxRx(SPI_UNIT_MCSPI2);
    }
    /** \brief SPI MCSPI3 ISR */
    FUNC(void, SPI_CODE_FAST) Spi_IrqUnitMcspi3TxRx(void)
    {
        Spi_IntISR_McuMcspiTxRx(SPI_UNIT_MCSPI3);
    }
    /** \brief SPI MCSPI4 ISR */
    FUNC(void, SPI_CODE_FAST) Spi_IrqUnitMcspi4TxRx(void)
    {
        Spi_IntISR_McuMcspiTxRx(SPI_UNIT_MCSPI4);
    }
    
    FUNC(void, SPI_CODE_FAST) Spi_IrqUnitMcuMcspi0DmaTx(void)
    {
        Spi_IntISR_McuMcspiDmaTx(SPI_MAX_HW_DMA_UNIT, SPI_UNIT_MCU_MCSPI0 );
    }
    FUNC(void, SPI_CODE_FAST) Spi_IrqUnitMcuMcspi0DmaRx(void)
    {
        Spi_IntISR_McuMcspiDmaRx(SPI_MAX_HW_DMA_UNIT, SPI_UNIT_MCU_MCSPI0 );
    }
    
    FUNC(void, SPI_CODE_FAST) Spi_IrqUnitMcuMcspi1DmaTx(void)
    {
        Spi_IntISR_McuMcspiDmaTx(SPI_MAX_HW_DMA_UNIT, SPI_UNIT_MCU_MCSPI1 );
    }
    FUNC(void, SPI_CODE_FAST) Spi_IrqUnitMcuMcspi1DmaRx(void)
    {
        Spi_IntISR_McuMcspiDmaRx(SPI_MAX_HW_DMA_UNIT, SPI_UNIT_MCU_MCSPI1 );
    }
    
    #define  SPI_STOP_SEC_ISR_CODE
    #include "Spi_MemMap.h"
    
    
    /*******************************************************************************
     *  END OF FILE: Spi_PBcfg.c
     ******************************************************************************/
    
    1780.Spi_Cfg.hChange the SPI mode to DMA mode

  • Hello,

    Your configuration is improper,

    SPI_MAX_HW_DMA_UNIT is defined as 0 , it should not be zero if you are using DMA.
     
    I request you to check the configuration properly before testing with DMA.
    Regards
    Tarun Mukesh
     
  •  after change,spi initialization failed

  • Hello,

    In which API is it returning failure ? spi dma init itself is throwing failure for you.It still suggests the configuration is wrong.

    Please keep breakpoints to identify which API is returning failure condition.

    For reference : Same issue reported due to configuration earlier 

     https://e2e.ti.com/support/processors-group/processors/f/processors-forum/1552958/processor-sdk-j721s2-question-on-dma-for-mcu_mcspi0-in-mcu-domain-of-tda4vl?pifragment-323307=1

    Regards

    Tarun Mukesh

  •  According to the demo, the SPI interrupt was configured as CAT1. After enabling DMA, the generated code reported an error as shown in the figure.The SPI configuration file is attached as an attachment.4606.Spi.rar

  • Hi, Zhichao,

    There is one point need you to check the memory attribution of buffer gsTxXma. If it is Cacheable, then please help to change it to a non-cachable location. Thanks.

    Br, Tommy

  • Summary of three key point for Cache coherency operation for TX/RX buffer allocated in Cacheable memory. Using MCAL SPI example in SDK for reference:

    1. Buffer alignment definition:

    uint32 SpiApp_McspiTxBuffer[SPI_MAX_CHANNELS][RX_TX_BUF_SIZE_WORD] __attribute__((aligned(CacheP_CACHELINE_ALIGNMENT)));
    
    uint32 SpiApp_McspiRxBuffer[SPI_MAX_CHANNELS][RX_TX_BUF_SIZE_WORD] __attribute__((aligned(CacheP_CACHELINE_ALIGNMENT)));


    2. Writeback TX Buffer before start transmission:

    #if (STD_ON == SPI_DMA_ENABLE)
        for (index=0; index<cfgPtr->maxJobs; index++)
        {
            uint32 hwInd = 0;
            for(uint32 ind = 0; ind <= SPI_MAX_HW_UNIT; ind++) {
                if(cfgPtr->jobCfg[index].hwUnitId == cfgPtr->hwUnitCfg[ind].hwUnitId)
                {
                    hwInd = ind;
                    break;
                }
            }
            if (TRUE == cfgPtr->hwUnitCfg[hwInd].enabledmaMode)
            {
                for (chIndex=0; chIndex<cfgPtr->jobCfg[index].channelPerJob; chIndex++)
                {
                    uint32 ch = cfgPtr->jobCfg[index].channelList[chIndex];
                    SpiApp_wbCache((uint8 *)&SpiApp_McspiTxBuffer[ch][0U], byteLength[ch]);
                    SpiApp_wbCache((uint8 *)&SpiApp_McspiRxBuffer[ch][0U], byteLength[ch]);
                }
            }
        }
    #endif

    3. Invalidate RX buffer after receiving data:

    #if (STD_ON == SPI_DMA_ENABLE)
        for (index=0; index<cfgPtr->maxJobs; index++)
        {
            uint32 hwInd = 0;
            for(uint32 ind = 0; ind <= SPI_MAX_HW_UNIT; ind++) {
                if(cfgPtr->jobCfg[index].hwUnitId == cfgPtr->hwUnitCfg[ind].hwUnitId)
                {
                    hwInd = ind;
                    break;
                }
            }
            if (TRUE == cfgPtr->hwUnitCfg[hwInd].enabledmaMode)
            {
                for (chIndex=0; chIndex<cfgPtr->jobCfg[index].channelPerJob; chIndex++)
                {
                    uint32 ch = cfgPtr->jobCfg[index].channelList[chIndex];
                    SpiApp_invCache((uint8 *)&SpiApp_McspiRxBuffer[ch][0U], byteLength[ch]);
                }
            }
        }
    #endif

  • There is no issue for overnight testing after adding Cache coherency operations. Will close this ticket.