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.

AM5728: AM5728 SPI Test Application

Part Number: AM5728
Other Parts Discussed in Thread: TMDSEVM572X, SYSCONFIG

I enabled SPI 3 IOSet 2 in a pinmux file, created a custom board and rebuilt the pdk. I was able to generate SPI examples and use the custom board to run the examples. The two examples I ran were the "MCSPI_BasicExample_idkAM572x_c66xExampleProject" and "MCSSPI_Loopback_idkAM572x_c66xExampleProject". The only thing I modified was the board to point to my custom board.

I monitored the following exposed pins on P18:

  • spi3_sclk : E11 
  • spi3_d1 : B10
  • spi3_d0 : C11
  • spi3_cs0 : D11

These examples didn't seem to modify the outputs on the exposed pins. I didn't see the clock signal or see the CS0 oscillating when running the code. 

I would like to generate the "SPI_TestApplication" to see if it outputs to the exposed pins, but this project doesn't get generated when I run.

./pdkProjectCreate.sh AM572x all little spi all dsp

Two questions:

  1. How can I generate the SPI_TestApplication example for the AM5728 SoM? 
  2. Should I see the pins output correctly for the two example projects that I ran, or do they not output to the pins?
  • Hi Andre,

    Andre Henriques said:
    "MCSPI_BasicExample_idkAM572x_c66xExampleProject"

    This example is using idkAM572x McSPI3 to communicate with external industrial module. On your custom board, do you have something attached to AM572x McSPI3 module?

    This example is using below source code file. You can trace your code if the below functions are executed successful.

    ti/drv/spi/example/mcspi_serializer/src/main_mcspi_example.c

    ti/drv/spi/test/src/am572x/SPI_idkAM572x_board.c

    Andre Henriques said:

    I monitored the following exposed pins on P18:

    • spi3_sclk : E11 
    • spi3_d1 : B10
    • spi3_d0 : C11
    • spi3_cs0 : D11

    The first pin that needs to toggle is spi3_cs0. I would suggest you to dump McSPI3 pinmux, PRCM and module registers and check if you will have the expected values.

    Andre Henriques said:
    "MCSSPI_Loopback_idkAM572x_c66xExampleProject



    This example can be used if you have nothing attached to your AM572x McSPI modules. Note that this example is using McSPI1, not McSPI3. The source code is in below file:

    ti/drv/spi/example/mcspiLoopbackApp/src/mcspiLoopbackApp.c


    Andre Henriques said:

    I would like to generate the "SPI_TestApplication" to see if it outputs to the exposed pins, but this project doesn't get generated when I run.

    1
    ./pdkProjectCreate.sh AM572x all little spi all dsp

    This is the correct command to generate AM572x McSPI examples and tests.

    SPI_TestApplication corresponds to MCSPI_BasicExample_idkAM572x_c66xTestProject

    spiLoopback example corresponds to MCSPI_Loopback_idkAM572x_c66xExampleProject

    MCSPI_Serializer Example application corresponds to MCSPI_BasicExample_idkAM572x_c66xExampleProject

    Andre Henriques said:
    How can I generate the SPI_TestApplication example for the AM5728 SoM? 

    Run the command  "./pdkProjectCreate.sh AM572x all little spi all dsp", and explore MCSPI_BasicExample_idkAM572x_c66xTestProject

    Andre Henriques said:
    Should I see the pins output correctly for the two example projects that I ran, or do they not output to the pins?

    These should have valid signals on McSPi pins. You should see these pins to toggle.

    Regards,
    Pavel

  • I am not using a custom board. I am using an evmAM5728 board, so I don't have something attached to AM572x McSPI3 module. 

    Maybe a better question is to ask if there is any example code that will work for the evmAM5728 that would have the basic setup for a SPI interface on the DSP?

    I imported the "rtos_template_app_am572x_c66", however, this did not transfer any information over SPI.

  • Andre,

    Andre Henriques said:
    Maybe a better question is to ask if there is any example code that will work for the evmAM5728 that would have the basic setup for a SPI interface on the DSP?

    No, we do not have. TMDSEVM572X board does NOT have external device attached to some of its McSPI modules. What i can suggest you is to port and reuse spiLoopback example. You can adopt this example from AM572x IDK to AM572x EVM. This example is intended to demonstrate the SPI LLD API usage on the HW platforms where SPI memory is not available.

    Regards,
    Pavel

  • I'm new to TI and RTOS and just looking for some guidance or reference examples for the evmAM5728. What are the steps involved for porting the spiLoopback example?

  • Andre,

    You need to create file for evmAM572x, similar for idkAM572x

    pdk_am57xx_1_0_15/packages/ti/drv/spi/example/mcspiLoopbackApp/am572x/c66/bios/MCSPI_Loopback_idkAM572x_c66xExampleProject.txt

    pdk_am57xx_1_0_15/packages/ti/drv/spi/example/mcspiLoopbackApp/am572x/c66/bios/mcspi_loopback_c66_idkAM572x.cfg

    Thus you should be able to load the out file based on ti/drv/spi/example/mcspiLoopbackApp/src/mcspiLoopbackApp.c

    Regards,
    Pavel

  • Hey Pavel, 

    I copied the 2 files you mentioned and modified the following in each:

    • MCSPI_Loopback_idkAM572x_c66xExampleProject.txt: 
      • -ccs.linkFile "PDK_INSTALL_PATH/ti/drv/spi/example/mcspiLoopbackApp/am572x/c66/bios/mcspi_loopback_c66_evmAM572x.cfg" 
    • mcspi_loopback_c66_idkAM572x.cfg: 
      • Board.Settings.boardName = "evmAM572x";

    I generated the project, and loaded it onto the c66 DSP processor. When running the code I didn't see anything showing up on my oscilloscope on the SPI pins.

  • I have attached my code.

    MCSPI_Loopback_samAM572x_c66xExampleProject.tar.gz

    When I run the example with MCSPI_INSTANCE = 2, the McSPI Data does not transfer. 

    If I set the #define MCSPI_INSTANCE to 0, then McSPI Data Transmission is successful. However I didn't configure SPI 1 in my pinmux file, so I'm not sure why it's working.

    I believe I have configured the SPI3 registers correctly to use IOSet 2.

        HW_WR_REG32(CSL_MPU_CORE_PAD_IO_REGISTERS_REGS+CSL_CONTROL_CORE_PAD_IO_PAD_VOUT1_VSYNC,0x000C0008); // SPI3_SCLK (SPI3_IOSet_2)
        HW_WR_REG32(CSL_MPU_CORE_PAD_IO_REGISTERS_REGS+CSL_CONTROL_CORE_PAD_IO_PAD_VOUT1_DE,0x000C0008); // SPI3_D1 (SPI3_IOSet_2)
        HW_WR_REG32(CSL_MPU_CORE_PAD_IO_REGISTERS_REGS+CSL_CONTROL_CORE_PAD_IO_PAD_VOUT1_HSYNC,0x000C0008); // SPI3_D0 (SPI3_IOSet_2)
        HW_WR_REG32(CSL_MPU_CORE_PAD_IO_REGISTERS_REGS+CSL_CONTROL_CORE_PAD_IO_PAD_VOUT1_CLK,0x00060008); // SPI3_CS0 (SPI3_IOSet_2)
    

    I'm watching the following pins:

     Can you please let me know what I am doing wrong? I would like to see the SPI Loopback example working on SPI 3.

  • I think my problem may be related to the registries not being set correctly for the SPI interfaces other than SPI 1. I can modify the MCSPI_SYST for SPI1, but even when I try to directly change the registry for the other SPIs they will not update for some reason. Do you know why the SPI registries are not being set correctly?

    SPI 1
    MCSPI_SYST: 0
    MCSPI_MODULCTRL: 1
    MCSPI_CH0CONF: 939787260
    MCSPI_CH0CTRL: 512

    SPI 2
    MCSPI_SYST: 1208590628
    MCSPI_MODULCTRL: 2112076
    MCSPI_CH0CONF: 1208590636
    MCSPI_CH0CTRL: 1208590644

    SPI 3
    MCSPI_SYST: 1208713508
    MCSPI_MODULCTRL: 1430540109
    MCSPI_CH0CONF: 1208713516
    MCSPI_CH0CTRL: 1208713524

  • Andre,

    mcspiLoopbackApp.c is using McSPI1 by default, thus for using McSPI3 you are correct to change MCSPI_INSTANCE from 0 to 2. As you observe that McSPI1 is working fine, while McSPI3 not, I would suggest you to put breakpoint just before SPI_transfer() function and make register dump of below McSPI3 registers:

    CM_L4PER_MCSPI3_CLKCTRL

    CTRL_CORE_PAD_VOUT1_VSYNC

    CTRL_CORE_PAD_VOUT1_HSYNC

    CTRL_CORE_PAD_VOUT1_DE

    CTRL_CORE_PAD_VOUT1_CLK

    McSPI3 module registers - MCSPI_SYSCONFIG, MCSPI_SYSSTATUS, MCSPI_IRQSTATUS, MCSPI_IRQENABLE, MCSPI_SYST, MCSPI_MODULCTRL, MCSPI_CH0CONF, MCSPI_CH0STAT, MCSPI_CH0CTRL, MCSPI_TX0, MCSPI_RX0, MCSPI_XFERLEVEL, MCSPI_DAFTX, MCSPI_DAFRX

    I would also suggest you to run the default test, where McSPI1 module is used and you observe is working fine, then make the same register dump at the same location of the code (just before SPI_transfer) and compare the values with McSPI3.

    CM_L4PER_MCSPI1_CLKCTRL

    CTRL_CORE_PAD_SPI1_SCLK

    CTRL_CORE_PAD_SPI1_D1

    CTRL_CORE_PAD_SPI1_D0

    CTRL_CORE_PAD_SPI1_CS0

    CTRL_CORE_PAD_SPI1_CS1

    McSPI1 module registers - MCSPI_SYSCONFIG, MCSPI_SYSSTATUS, MCSPI_IRQSTATUS, MCSPI_IRQENABLE, MCSPI_SYST, MCSPI_MODULCTRL, MCSPI_CH0CONF, MCSPI_CH1CONF, MCSPI_CH0STAT, MCSPI_CH1STAT, MCSPI_CH0CTRL, MCSPI_CH1CTRL, MCSPI_TX0, MCSPI_TX1, MCSPI_RX0, MCSPI_RX1, MCSPI_XFERLEVEL, MCSPI_DAFTX, MCSPI_DAFRX


    I would also note that we have one more McSPI test, that should be running by default on AM572x EVM.

    PDK_AM57x/packages/ti/csl/example/mcspi/mcspiMasterSlave/mcspiMasterSlave_spi1_spi2.c

    McSPI1 is master and transfer data to McSPI2 slave. You need to connect McSPI1 data out pin to McSPI2 data in pin.

    Regards,
    Pavel

  • Thanks for the response. I will try these recommendations tomorrow. With regards to the comment "connect McSPI1 data out pin to McSPI2 data in pin". How do you connect these pins together if they are not exposed on the AM572x EVM?

  • Andre Henriques said:
    With regards to the comment "connect McSPI1 data out pin to McSPI2 data in pin". How do you connect these pins together if they are not exposed on the AM572x EVM?

    You will need HW changes of the EVM.

    Regards,
    Pavel

  • I have run the example again printing out all the registers you mentioned for SPI 1, 2, 3 and 4.

    The code I used is attached here: LoopbackSPI3Problem.tar.gz

    In order to get SPI 2 and 4 working I had to enable their clocks and set their sclk, d1, d0 and cs0 pins as follows:

        // SPI 2
        HW_WR_REG32(0x4A0097F8, 0x00000002); // Start SPI2 L4PER Clock Control
        HW_WR_REG32(CSL_MPU_CORE_PAD_IO_REGISTERS_REGS+CSL_CONTROL_CORE_PAD_IO_PAD_SPI2_SCLK,0x000C0000);
        HW_WR_REG32(CSL_MPU_CORE_PAD_IO_REGISTERS_REGS+CSL_CONTROL_CORE_PAD_IO_PAD_SPI2_D1,0x000C0000);
        HW_WR_REG32(CSL_MPU_CORE_PAD_IO_REGISTERS_REGS+CSL_CONTROL_CORE_PAD_IO_PAD_SPI2_D0,0x000C0000);
        HW_WR_REG32(CSL_MPU_CORE_PAD_IO_REGISTERS_REGS+CSL_CONTROL_CORE_PAD_IO_PAD_SPI2_CS0,0x00060000);
    
    
        // SPI 4
        HW_WR_REG32(0x4A009808, 0x00000002); // Start SPI4 L4PER Clock Control
        HW_WR_REG32(CSL_MPU_CORE_PAD_IO_REGISTERS_REGS+CSL_CONTROL_CORE_PAD_IO_PAD_GPMC_A8,0x000C0008); // SPI4_SCLK (SPI4_IOSet_1)
        HW_WR_REG32(CSL_MPU_CORE_PAD_IO_REGISTERS_REGS+CSL_CONTROL_CORE_PAD_IO_PAD_GPMC_A9,0x000C0008); // SPI4_D1 (SPI4_IOSet_1)
        HW_WR_REG32(CSL_MPU_CORE_PAD_IO_REGISTERS_REGS+CSL_CONTROL_CORE_PAD_IO_PAD_GPMC_A10,0x000C0008); // SPI4_D0 (SPI4_IOSet_1)
        HW_WR_REG32(CSL_MPU_CORE_PAD_IO_REGISTERS_REGS+CSL_CONTROL_CORE_PAD_IO_PAD_GPMC_A11,0x00060008); // SPI4_CS0 (SPI4_IOSet_1)

    However when setting the same registries for SPI 3 it did not get past the SPI_transfer function. Below are my configurations for SPI 3. I also tried with the IOSet 1 pins.

        // SPI 3
        HW_WR_REG32(0x4A009800, 0x00000002); // Start SPI3 L4PER Clock Control
    //    HW_WR_REG32(CSL_MPU_CORE_PAD_IO_REGISTERS_REGS+CSL_CONTROL_CORE_PAD_IO_PAD_VIN1A_DE0,0x000C0008); // SPI3_SCLK (SPI3_IOSet_1)
    //    HW_WR_REG32(CSL_MPU_CORE_PAD_IO_REGISTERS_REGS+CSL_CONTROL_CORE_PAD_IO_PAD_VIN1A_FLD0,0x000C0008); // SPI3_D1 (SPI3_IOSet_1)
    //    HW_WR_REG32(CSL_MPU_CORE_PAD_IO_REGISTERS_REGS+CSL_CONTROL_CORE_PAD_IO_PAD_VIN1A_HSYNC0,0x000C0008); // SPI3_D0 (SPI3_IOSet_1)
    //    HW_WR_REG32(CSL_MPU_CORE_PAD_IO_REGISTERS_REGS+CSL_CONTROL_CORE_PAD_IO_PAD_VIN1A_VSYNC0,0x00060008); // SPI3_CS0 (SPI3_IOSet_1)
    
        HW_WR_REG32(CSL_MPU_CORE_PAD_IO_REGISTERS_REGS+CSL_CONTROL_CORE_PAD_IO_PAD_VOUT1_VSYNC,0x000C0008); // SPI3_SCLK (SPI3_IOSet_2)
        HW_WR_REG32(CSL_MPU_CORE_PAD_IO_REGISTERS_REGS+CSL_CONTROL_CORE_PAD_IO_PAD_VOUT1_DE,0x000C0008); // SPI3_D1 (SPI3_IOSet_2)
        HW_WR_REG32(CSL_MPU_CORE_PAD_IO_REGISTERS_REGS+CSL_CONTROL_CORE_PAD_IO_PAD_VOUT1_HSYNC,0x000C0008); // SPI3_D0 (SPI3_IOSet_2)
        HW_WR_REG32(CSL_MPU_CORE_PAD_IO_REGISTERS_REGS+CSL_CONTROL_CORE_PAD_IO_PAD_VOUT1_CLK,0x00060008); // SPI3_CS0 (SPI3_IOSet_2)

    Below is an output from all the registers you mentioned for each SPI.

    SPI1
    McSPI Internal Loopback test app started
    The Mode of transfer is Interrupt Mode
    MCSPI_HL_REV: 1076892171
    MCSPI_HL_HWINFO: 17
    MCSPI_HL_SYSCONFIG: 4
    MCSPI_REVISION: 43
    MCSPI_SYSCONFIG: 776
    MCSPI_SYSSTATUS: 1
    MCSPI_IRQSTATUS: 0
    MCSPI_IRQENABLE: 0
    MCSPI_WAKEUPENABLE: 0
    MCSPI_SYST: 0
    MCSPI_MODULCTRL: 1
    MCSPI_CH0CONF: 537134076
    MCSPI_CH1CONF: 393216
    MCSPI_CH2CONF: 393216
    MCSPI_CH3CONF: 393216
    MCSPI_CH0STAT: 0
    MCSPI_CH1STAT: 0
    MCSPI_CH2STAT: 0
    MCSPI_CH3STAT: 0
    MCSPI_CH0CTRL: 512
    MCSPI_CH1CTRL: 0
    MCSPI_CH2CTRL: 0
    MCSPI_CH3CTRL: 0
    MCSPI_TX0: 0
    MCSPI_TX1: 0
    MCSPI_TX2: 0
    MCSPI_TX3: 0
    MCSPI_RX0: 0
    MCSPI_RX1: 0
    MCSPI_RX2: 0
    MCSPI_RX3: 0
    MCSPI_XFERLEVEL: 0
    CTRL_CORE_PAD_SPI1_SCLK: 786432
    CTRL_CORE_PAD_SPI1_D1: 786432
    CTRL_CORE_PAD_SPI1_D0: 786432
    CTRL_CORE_PAD_SPI1_CS0: 393216
    CTRL_CORE_PAD_SPI1_CS1: 393216
    SPI3_SCLK: 786440
    SPI3_D1: 786440
    SPI3_D0: 786440
    SPI3_CS0: 393224
    SPI3_CS1: 327694
    CM_L4PER_MCSPI1_CLKCTRL: 2
    CM_L4PER_MCSPI2_CLKCTRL: 2
    CM_L4PER_MCSPI3_CLKCTRL: 2
    CM_L4PER_MCSPI4_CLKCTRL: 2
    McSPI Data Transmission is successful
    
    
    SPI2
    McSPI Internal Loopback test app started
    The Mode of transfer is Interrupt Mode
    MCSPI_HL_REV: 1076892171
    MCSPI_HL_HWINFO: 17
    MCSPI_HL_SYSCONFIG: 4
    MCSPI_REVISION: 43
    MCSPI_SYSCONFIG: 776
    MCSPI_SYSSTATUS: 1
    MCSPI_IRQSTATUS: 0
    MCSPI_IRQENABLE: 0
    MCSPI_WAKEUPENABLE: 0
    MCSPI_SYST: 0
    MCSPI_MODULCTRL: 1
    MCSPI_CH0CONF: 537134076
    MCSPI_CH1CONF: 393216
    MCSPI_CH2CONF: 393216
    MCSPI_CH3CONF: 393216
    MCSPI_CH0STAT: 0
    MCSPI_CH1STAT: 0
    MCSPI_CH2STAT: 0
    MCSPI_CH3STAT: 0
    MCSPI_CH0CTRL: 512
    MCSPI_CH1CTRL: 0
    MCSPI_CH2CTRL: 0
    MCSPI_CH3CTRL: 0
    MCSPI_TX0: 0
    MCSPI_TX1: 0
    MCSPI_TX2: 0
    MCSPI_TX3: 0
    MCSPI_RX0: 0
    MCSPI_RX1: 0
    MCSPI_RX2: 0
    MCSPI_RX3: 0
    MCSPI_XFERLEVEL: 0
    CTRL_CORE_PAD_SPI1_SCLK: 786432
    CTRL_CORE_PAD_SPI1_D1: 786432
    CTRL_CORE_PAD_SPI1_D0: 786432
    CTRL_CORE_PAD_SPI1_CS0: 393216
    CTRL_CORE_PAD_SPI1_CS1: 393216
    SPI3_SCLK: 786440
    SPI3_D1: 786440
    SPI3_D0: 786440
    SPI3_CS0: 393224
    SPI3_CS1: 327694
    CM_L4PER_MCSPI1_CLKCTRL: 2
    CM_L4PER_MCSPI2_CLKCTRL: 2
    CM_L4PER_MCSPI3_CLKCTRL: 2
    CM_L4PER_MCSPI4_CLKCTRL: 2
    McSPI Data Transmission is successful
    
    
    SPI3
    McSPI Internal Loopback test app started
    The Mode of transfer is Interrupt Mode
    MCSPI_HL_REV: 1076892171
    MCSPI_HL_HWINFO: 17
    MCSPI_HL_SYSCONFIG: 4
    MCSPI_REVISION: 43
    MCSPI_SYSCONFIG: 776
    MCSPI_SYSSTATUS: 1
    MCSPI_IRQSTATUS: 0
    MCSPI_IRQENABLE: 0
    MCSPI_WAKEUPENABLE: 0
    MCSPI_SYST: 0
    MCSPI_MODULCTRL: 1
    MCSPI_CH0CONF: 537134076
    MCSPI_CH1CONF: 393216
    MCSPI_CH2CONF: 393216
    MCSPI_CH3CONF: 393216
    MCSPI_CH0STAT: 0
    MCSPI_CH1STAT: 0
    MCSPI_CH2STAT: 0
    MCSPI_CH3STAT: 0
    MCSPI_CH0CTRL: 512
    MCSPI_CH1CTRL: 0
    MCSPI_CH2CTRL: 0
    MCSPI_CH3CTRL: 0
    MCSPI_TX0: 0
    MCSPI_TX1: 0
    MCSPI_TX2: 0
    MCSPI_TX3: 0
    MCSPI_RX0: 0
    MCSPI_RX1: 0
    MCSPI_RX2: 0
    MCSPI_RX3: 0
    MCSPI_XFERLEVEL: 0
    CTRL_CORE_PAD_SPI1_SCLK: 786432
    CTRL_CORE_PAD_SPI1_D1: 786432
    CTRL_CORE_PAD_SPI1_D0: 786432
    CTRL_CORE_PAD_SPI1_CS0: 393216
    CTRL_CORE_PAD_SPI1_CS1: 393216
    SPI3_SCLK: 786440
    SPI3_D1: 786440
    SPI3_D0: 786440
    SPI3_CS0: 393224
    SPI3_CS1: 327694
    CM_L4PER_MCSPI1_CLKCTRL: 2
    CM_L4PER_MCSPI2_CLKCTRL: 2
    CM_L4PER_MCSPI3_CLKCTRL: 2
    CM_L4PER_MCSPI4_CLKCTRL: 2
    
    
    SPI4
    McSPI Internal Loopback test app started
    The Mode of transfer is Interrupt Mode
    MCSPI_HL_REV: 1076892171
    MCSPI_HL_HWINFO: 17
    MCSPI_HL_SYSCONFIG: 4
    MCSPI_REVISION: 43
    MCSPI_SYSCONFIG: 776
    MCSPI_SYSSTATUS: 1
    MCSPI_IRQSTATUS: 0
    MCSPI_IRQENABLE: 0
    MCSPI_WAKEUPENABLE: 0
    MCSPI_SYST: 0
    MCSPI_MODULCTRL: 1
    MCSPI_CH0CONF: 537134076
    MCSPI_CH1CONF: 393216
    MCSPI_CH2CONF: 393216
    MCSPI_CH3CONF: 393216
    MCSPI_CH0STAT: 0
    MCSPI_CH1STAT: 0
    MCSPI_CH2STAT: 0
    MCSPI_CH3STAT: 0
    MCSPI_CH0CTRL: 512
    MCSPI_CH1CTRL: 0
    MCSPI_CH2CTRL: 0
    MCSPI_CH3CTRL: 0
    MCSPI_TX0: 0
    MCSPI_TX1: 0
    MCSPI_TX2: 0
    MCSPI_TX3: 0
    MCSPI_RX0: 0
    MCSPI_RX1: 0
    MCSPI_RX2: 0
    MCSPI_RX3: 0
    MCSPI_XFERLEVEL: 0
    CTRL_CORE_PAD_SPI1_SCLK: 786432
    CTRL_CORE_PAD_SPI1_D1: 786432
    CTRL_CORE_PAD_SPI1_D0: 786432
    CTRL_CORE_PAD_SPI1_CS0: 393216
    CTRL_CORE_PAD_SPI1_CS1: 393216
    SPI3_SCLK: 786440
    SPI3_D1: 786440
    SPI3_D0: 786440
    SPI3_CS0: 393224
    SPI3_CS1: 327694
    CM_L4PER_MCSPI1_CLKCTRL: 2
    CM_L4PER_MCSPI2_CLKCTRL: 2
    CM_L4PER_MCSPI3_CLKCTRL: 2
    CM_L4PER_MCSPI4_CLKCTRL: 2
    McSPI Data Transmission is successful

    Can you please let me know what you think might be the problem with getting SPI 3 working on IOSet 2? 

  • Andre Henriques said:
    SPI3_SCLK: 786440
    SPI3_D1: 786440
    SPI3_D0: 786440
    SPI3_CS0: 393224
    SPI3_CS1: 327694

    Andre,

    My request was to make register dump of below McSPI3 pinmux registers:

    CTRL_CORE_PAD_VOUT1_VSYNC

    CTRL_CORE_PAD_VOUT1_HSYNC

    CTRL_CORE_PAD_VOUT1_DE

    CTRL_CORE_PAD_VOUT1_CLK

    If the above quoted registers values corresponds to these McSPI3 registers, then your pinmux settings are not correct. For example:

    CTRL_CORE_PAD_VOUT1_VSYNC[3:0] VOUT1_VSYNC_MUXMODE value should be 0x8 (spi3_sclk), while you have 0x0 (vout1_vsync), check AM572x TRM, Table 18-1397. CTRL_CORE_PAD_VOUT1_VSYNC.

    I would suggest you to put a breakpoint right after padConfig_prcmEnable() function and explore SPI3 pinmux registers from the CCS menu. What values you have at that point?

    Also note that below AM572x pins you need to use for this McSPI3 pinmux:

    E11 - VOUT1_VSYNC.spi3_sclk

    C11 - VOUT1_HSYNC.spi3_d0

    B10 - VOUT1_DE.spi3_d1

    D11 - VOUT1_CLK.spi3_cs0


    Regards,
    Pavel

  • Yes, sorry for any confusion. I changed the names for my own clarity. The conversions are as follows:

    SPI3_SCLK  = CSL_CONTROL_CORE_PAD_IO_PAD_VOUT1_VSYNC,
    SPI3_D1       = CSL_CONTROL_CORE_PAD_IO_PAD_VOUT1_DE,
    SPI3_D0       = CSL_CONTROL_CORE_PAD_IO_PAD_VOUT1_HSYNC,
    SPI3_CS0     = CSL_CONTROL_CORE_PAD_IO_PAD_VOUT1_CLK,
    SPI3_CS1     = CSL_CONTROL_CORE_PAD_IO_PAD_VOUT1_FLD

    I was suspecting that the pinmux settings were the issue, but can't figure out why it's only affecting SPI3. I didn't modify the pinmux on the evmAM572x. I assume I should be able to resolve this issue by using the TI PinMux Tool and copying the following files into the following directory.

    Copy Files 

    • boardPadDelay.h
    • boardPadDelayDevice.c
    • boardPadDelayInit.c
    • boardPadDelayTune.h

    Into Directory

    • ~/ti/pdk_am57xx_1_0_15/packages/ti/board/src/evmAM572x/

    Then rebuilding the board as follows:

    • cd ~/ti/pdk_am57xx_1_0_15/packages
    • source pdksetupenv.sh
    • make board_lib

    Are these assumptions correct?

  • Also, to clarify another point. The values for the registers were not converted to hex, so that may have been misleading. The hex representation is as follows.

    SPI3_SCLK: 786440 (0xC0008)
    SPI3_D1: 786440 (0xC0008)
    SPI3_D0: 786440 (0xC0008)
    SPI3_CS0: 393224 (0x60008)

    These show the mux modes were all set to 0x8.

  • Andre,

    Andre Henriques said:
    SPI3_SCLK: 786440 (0xC0008)
    SPI3_D1: 786440 (0xC0008)
    SPI3_D0: 786440 (0xC0008)
    SPI3_CS0: 393224 (0x60008)

    You pinmux looks correct.

    From what I understand McSPI1/2/4 are working fine, while McSPI3 fails. I would suggest you to put new breakpoint right after SPI_transfer() function and make new register dump of McSPI1 and McSPI3 pinmux and modules registers. Check if there will be any difference.

    You can also probe McSPI1 and McSPI3 pins with scope, during SPI_transfer() function execution, and check the signals there.

    As you do not have neither echoPrompt2 nor echoPrompt3 messages for McSPI3, seems the flow hang.

    Regards,
    Pavel

  • Your understanding is correct. When running McSPI3, it never gets past SPI_transfer(). I verified there's no activity on the McSPI3 pins. Does the code I sent work for you when you run it on the evmAM5728?

  • Andre,

    I have tested mcspiLoopbackApp example on idkAM572x board first, and I see it fails for McSPI1 (default source code). I have on UART (not CCS) console:

    McSPI Internal Loopback test app started
    The Mode of transfer is Interrupt Mode
    McSPI Data Transmission is Failed

    I have tried with both ARM and C66x DSP examples, both have the same result. I will check with our McSPI RTOS experts for more details regarding this example.

    Meanwhile, could you please answer below questions:

    1. Have you tried this example on AM572x IDK board? If yes, what is the result for McSPI1/3?

    2. When you run this example on AM572x EVM board, where McSPI1 works fine, have you made any HW or SW changes in this example for McSPI1?

     

    Regards,
    Pavel

  • Hey Pavel,

    1. No, I haven't tried this on the IDK board.

    2. No, this is using the TI evm AM5728 board and default software from the SPI Loopback example. The problem occurs only for SPI 3 in this example where I only added the necessary registers to configure SPI 3 to match SPI 1.

    Regards,

    Andre

  • I wanted to follow up and verify if you were able to get the SPI 3 interface working on the evmAM5728 board?

  • Andre Henriques said:
    Your understanding is correct. When running McSPI3, it never gets past SPI_transfer(). I verified there's no activity on the McSPI3 pins. Does the code I sent work for you when you run it on the evmAM5728?

    At this point, check if McSPI3 is enabled in PRCM. We have similar issue for AM437x EVM board:

    Trace where exactly your code hang and dump again SPI3 pinmux, PRCM and module registers. Check if there has been any difference.

    Regards,
    Pavel

  • Andre,

    I was able to run this McSPI loopback test on idkAM572x SPI3 successful, I have below UART console output:

    McSPI Internal Loopback test app started
    The Mode of transfer is Interrupt Mode
    McSPI Data Transmission is successful


    I am testing on Cortex-A15 core, but should be the same for DSP C66x. I am using SPI3 IOSET1. I have modified only ti/drv/spi/example/mcspiLoopbackApp/src/mcspiLoopbackApp.c file. Please find attached:

     /*
     *  Copyright (C) 2015-2017 Texas Instruments Incorporated - http://www.ti.com/
     *
     *  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, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
     *  A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
     *  OWNER OR CONTRIBUTORS 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   mcspiLoopbackApp.c
     *
     *  \brief This file contains the application which demonstrates McSPI loopback
     *         which transfers some data pattern from data I/O signal & receives
     *         the data from same data I/O signal.
     *
     */
    
    /* ========================================================================== */
    /*                             Include Files                                  */
    /* ========================================================================== */
    /* XDCtools Header files */
    #include <xdc/std.h>
    #include <xdc/cfg/global.h>
    #include <xdc/runtime/Error.h>
    #include <xdc/runtime/System.h>
    
    /* BIOS Header files */
    #include <ti/sysbios/BIOS.h>
    #include <ti/sysbios/knl/Task.h>
    
    #include "stdint.h"
    #include <stdio.h>
    #include <ti/csl/example/utils/common/inc/app_utils.h>
    #include <ti/csl/soc.h>
    #include <ti/csl/hw_types.h>
    
    #include <ti/board/board.h>
    
    #include <ti/osal/osal.h>
    
    /* UART Header files */
    #include <ti/drv/uart/UART.h>
    
    /* SPI Header files */
    #include <ti/drv/spi/SPI.h>
    #include <ti/csl/csl_mcspi.h>
    #include <ti/drv/spi/soc/SPI_soc.h>
    #if defined SOC_AM335x
    #include "am335x_pinmux.h"
    #endif
    #if defined SOC_AM437x
    #include "am43xx_pinmux.h"
    #endif
    #if defined(SOC_AM335x) || defined(SOC_AM437x)
    #include "chipdb_defs.h"
    #endif
    
    /* ========================================================================== */
    /*                                 Macros                                     */
    /* ========================================================================== */
    
    #define McSPI_DATA_COUNT            50U // Data Count Transaction
    
    #if defined(SOC_AM571x) || defined (SOC_AM572x) || defined (SOC_AM574x)
    #define UART_INSTANCE 2
    #else
    #define UART_INSTANCE 0
    #endif
    
    #define MCSPI_INSTANCE 2
    
    /* ========================================================================== */
    /*                            Global Variables                                */
    /* ========================================================================== */
    uint8_t           gRxBuffer[McSPI_DATA_COUNT];
    uint8_t           gTxBuffer[McSPI_DATA_COUNT];
    
    UART_Handle gUartHandle;
    
    SPI_Handle gSpiHandle;
    
    /* UART parameters structure*/
    const UART_Params gUserParams = {
        UART_MODE_BLOCKING,     /* readMode */
        UART_MODE_BLOCKING,     /* writeMode */
        SemaphoreP_WAIT_FOREVER,/* readTimeout */
        SemaphoreP_WAIT_FOREVER,/* writeTimeout */
        NULL,                  /* readCallback */
        NULL,                 /* writeCallback */
        UART_RETURN_NEWLINE,  /* readReturnMode */
        UART_DATA_TEXT,       /* readDataMode */
        UART_DATA_TEXT,       /* writeDataMode */
        UART_ECHO_ON,         /* readEcho */
        115200,               /* baudRate */
        UART_LEN_8,           /* dataLength */
        UART_STOP_ONE,        /* stopBits */
        UART_PAR_NONE         /* parityType */
    };
    
    /* SPI parameters structure Master mode*/
    SPI_Params gSpiParams = {
        SPI_MODE_BLOCKING,  /* transferMode */
        SemaphoreP_WAIT_FOREVER,/* transferTimeout */
        NULL,               /* transferCallbackFxn */
        SPI_MASTER,         /* mode */
        1000000,            /* bitRate */
        8,                  /* dataSize */
        SPI_POL0_PHA0,      /* frameFormat */
        NULL                /* custom */
    };
    
    /* ========================================================================== */
    /*                          Function Declarations                             */
    /* ========================================================================== */
    static void McSPIInitializeBuffers(void);
    void padConfig_prcmEnable();
    void spi_test(UArg arg0, UArg arg1);
    static int32_t McSPIVerifyData(void);
    
    /* ========================================================================== */
    /*                          Function Definitions                              */
    /* ========================================================================== */
    void padConfig_prcmEnable()
    {
    #if defined (SOC_DRA72x) || (SOC_DRA75x) || defined (SOC_DRA78x)
        Board_initCfg boardCfg;
    
        boardCfg = BOARD_INIT_PINMUX_CONFIG |
            BOARD_INIT_MODULE_CLOCK;
    
        Board_init(boardCfg);
    #endif
        /* Loopback mode is not available for MCSPI. To test Loopback on McSPI,
         * Receive Bit is enabled on both Tx and Rx pins of McSPI
         */
    #if defined(SOC_AM571x) || defined (SOC_AM572x) || defined (SOC_AM574x)
        HW_WR_REG32(CSL_MPU_CORE_PAD_IO_REGISTERS_REGS+CSL_CONTROL_CORE_PAD_IO_PAD_UART2_CTSN, 0x00050002);
        HW_WR_REG32(CSL_MPU_CORE_PAD_IO_REGISTERS_REGS+CSL_CONTROL_CORE_PAD_IO_PAD_UART2_RTSN, 0x00010001);
        //HW_WR_REG32(CSL_MPU_CORE_PAD_IO_REGISTERS_REGS+CSL_CONTROL_CORE_PAD_IO_PAD_SPI1_SCLK,0x000C0000);
        //HW_WR_REG32(CSL_MPU_CORE_PAD_IO_REGISTERS_REGS+CSL_CONTROL_CORE_PAD_IO_PAD_SPI1_D1,0x000C0000);
        //HW_WR_REG32(CSL_MPU_CORE_PAD_IO_REGISTERS_REGS+CSL_CONTROL_CORE_PAD_IO_PAD_SPI1_D0,0x000C0000);
        //HW_WR_REG32(CSL_MPU_CORE_PAD_IO_REGISTERS_REGS+CSL_CONTROL_CORE_PAD_IO_PAD_SPI1_CS0,0x00060000);
    
    //IOSET1
    
        HW_WR_REG32(CSL_MPU_CORE_PAD_IO_REGISTERS_REGS+CSL_CONTROL_CORE_PAD_IO_PAD_VIN1A_DE0,0x000C0008);
        HW_WR_REG32(CSL_MPU_CORE_PAD_IO_REGISTERS_REGS+CSL_CONTROL_CORE_PAD_IO_PAD_VIN1A_FLD0,0x000C0008); //d1
        HW_WR_REG32(CSL_MPU_CORE_PAD_IO_REGISTERS_REGS+CSL_CONTROL_CORE_PAD_IO_PAD_VIN1A_HSYNC0,0x000C0008); //d0
        HW_WR_REG32(CSL_MPU_CORE_PAD_IO_REGISTERS_REGS+CSL_CONTROL_CORE_PAD_IO_PAD_VIN1A_VSYNC0,0x00060008);
    
        /*MCSPI3 prcm*/
        //CM_CORE__L4PER 0x4A009700
        //CM_L4PER_MCSPI3_CLKCTRL 0x100
            HW_WR_REG32(0x4A009700 + 0x100, 0x02);
            while (HW_RD_REG32(0x4A009700 + 0x100) !=
                    0x02U)
                {
                    ;
                }
    
        #if defined (_TMS320C6X)
        /*
         * AM57x DSP does not have a default Xbar connection for UART
         * interrupts, need to use a reserved IRQ Xbar instance for Xbar
         * interrupt configuration
         */
         /* Use reserved XBAR_INST_DSP1_IRQ_34 */
        CSL_xbarIrqConfigure(CSL_XBAR_IRQ_CPU_ID_DSP1, CSL_XBAR_INST_DSP1_IRQ_34, CSL_XBAR_UART3_IRQ);
    #endif
    #if defined (SOC_AM572x) || defined(SOC_AM574x)
        //HW_WR_REG32(CSL_MPU_CORE_PAD_IO_REGISTERS_REGS+CSL_CONTROL_CORE_PAD_IO_PAD_SPI1_CS1,0x00060000);
        HW_WR_REG32(CSL_MPU_CORE_PAD_IO_REGISTERS_REGS+CSL_CONTROL_CORE_PAD_IO_PAD_MMC3_DAT3,0x00060001);  //IOSET1
    #endif
    #endif
    #if defined (SOC_TDA2XX) || defined(SOC_TDA2PX) || defined (SOC_TDA2EX)
        /*Pad configurations */
        HW_WR_REG32(SOC_CORE_PAD_IO_REGISTERS_BASE+CTRL_CORE_PAD_UART1_RXD,0x00040000);
        HW_WR_REG32(SOC_CORE_PAD_IO_REGISTERS_BASE+CTRL_CORE_PAD_UART1_TXD,0x00040000);
        HW_WR_REG32(SOC_CORE_PAD_IO_REGISTERS_BASE+CTRL_CORE_PAD_SPI1_SCLK,0x000C0000);
        HW_WR_REG32(SOC_CORE_PAD_IO_REGISTERS_BASE+CTRL_CORE_PAD_SPI1_D1,0x000C0000);
        HW_WR_REG32(SOC_CORE_PAD_IO_REGISTERS_BASE+CTRL_CORE_PAD_SPI1_D0,0x000C0000);
        HW_WR_REG32(SOC_CORE_PAD_IO_REGISTERS_BASE+CTRL_CORE_PAD_SPI1_CS0,0x00060000);
    #if defined (SOC_TDA2XX) || defined(SOC_TDA2PX)
        HW_WR_REG32(SOC_CORE_PAD_IO_REGISTERS_BASE+CTRL_CORE_PAD_SPI1_CS1,0x00060000);
    #endif
        /* IPU1 Crossbar */
        CSL_xbarIrqConfigure(CSL_XBAR_IRQ_CPU_ID_IPU1, CSL_XBAR_INST_IPU1_IRQ_44, CSL_XBAR_UART1_IRQ);
    #endif
    #if defined(SOC_TDA3XX)
        /*MCSPI1 prcm*/
        HW_WR_REG32(SOC_L4PER_CM_CORE_BASE + CM_L4PER_MCSPI1_CLKCTRL, 0x02);
        while (HW_RD_REG32(SOC_L4PER_CM_CORE_BASE + CM_L4PER_MCSPI1_CLKCTRL) !=
                0x02U)
            {
                ;
            }
        HW_WR_REG32(SOC_CORE_PAD_IO_REGISTERS_BASE+CTRL_CORE_PAD_IO_UART1_RXD,0x00040000);
        HW_WR_REG32(SOC_CORE_PAD_IO_REGISTERS_BASE+CTRL_CORE_PAD_IO_UART1_TXD,0x00000000);
        HW_WR_REG32(SOC_CORE_PAD_IO_REGISTERS_BASE+CTRL_CORE_PAD_IO_SPI1_CS0,0x00040000);
        HW_WR_REG32(SOC_CORE_PAD_IO_REGISTERS_BASE+CTRL_CORE_PAD_IO_SPI1_SCLK,0x00040000);
        HW_WR_REG32(SOC_CORE_PAD_IO_REGISTERS_BASE+CTRL_CORE_PAD_IO_SPI1_D0,0x00040000);
        HW_WR_REG32(SOC_CORE_PAD_IO_REGISTERS_BASE+CTRL_CORE_PAD_IO_SPI1_D1,0x00040000);
    
        /* IPU1 crossbar */
    #if defined (__TI_ARM_V7M4__)
        CSL_xbarIrqConfigure(CSL_XBAR_IRQ_CPU_ID_IPU1, CSL_XBAR_INST_IPU1_IRQ_44, CSL_XBAR_UART1_IRQ);
    #elif defined(_TMS320C6X)
        CSL_xbarIrqConfigure(CSL_XBAR_IRQ_CPU_ID_DSP1, CSL_XBAR_INST_DSP1_IRQ_44, CSL_XBAR_UART1_IRQ);
    #endif
    #endif
    #if defined(SOC_AM335x) || defined(SOC_AM437x)
        uint32_t ctrlModBase;
    
        /* UART */
        ctrlModBase = CHIPDBBaseAddress(CHIPDB_MOD_ID_CONTROL_MODULE, UART_INSTANCE);
        HW_WR_REG32(ctrlModBase+PIN_UART0_TXD, PIN_MODE(0));
        HW_WR_REG32(ctrlModBase+PIN_UART0_RXD, PIN_MODE(0) | PIN_RX_ACTIVE);
        /* SPI0 */
        ctrlModBase = CHIPDBBaseAddress(CHIPDB_MOD_ID_CONTROL_MODULE, MCSPI_INSTANCE);
        HW_WR_REG32(ctrlModBase+PIN_SPI0_SCLK, PIN_MODE(0) | PIN_RX_ACTIVE);
        HW_WR_REG32(ctrlModBase+PIN_SPI0_D0, PIN_MODE(0) | PIN_RX_ACTIVE);
        HW_WR_REG32(ctrlModBase+PIN_SPI0_D1, PIN_MODE(0) | PIN_RX_ACTIVE);
        HW_WR_REG32(ctrlModBase+PIN_SPI0_CS0, PIN_MODE(0) | PIN_RX_ACTIVE);
    #endif
    }
    
    void spi_initConfig(void)
    {
        SPI_v1_HWAttrs spi_cfg;
    
        /* Get the default UART init configurations */
        SPI_socGetInitCfg(MCSPI_INSTANCE, &spi_cfg);
    
        /* Modify the default SPI configurations if necessary */
        spi_cfg.chnCfg[spi_cfg.chNum].dataLineCommMode = MCSPI_DATA_LINE_COMM_MODE_4;
    
        /* Set the default UART init configurations */
        SPI_socSetInitCfg(MCSPI_INSTANCE, &spi_cfg);
    }
    
    int main(void)
    {
        Task_Handle task;
        Error_Block eb;
    
        Error_init(&eb);
    
        task = Task_create(spi_test, NULL, &eb);
        if (task == NULL) {
            System_printf("Task_create() failed!\n");
            BIOS_exit(0);
        }
    
        /* Start BIOS */
        BIOS_start();
        return (0);
    }
    
    void spi_test(UArg arg0, UArg arg1)
    {
        UART_Params      params;
        int32_t retVal;
        SPI_Transaction transaction;
    #if defined(SOC_AM335x) || defined(SOC_AM437x) || defined(SOC_AM571x) || defined (SOC_AM572x) || defined (SOC_AM574x)
        Board_initCfg boardCfg;
    #endif
    
        char echoPrompt[] = "\nMcSPI Internal Loopback test app started";
        char echoPrompt1[] = "\nThe Mode of transfer is Interrupt Mode";
        char echoPrompt2[] = "\nMcSPI Data Transmission is successful";
        char echoPrompt3[] = "\nMcSPI Data Transmission is Failed";
    
    #if defined(SOC_AM335x) || defined(SOC_AM437x) || defined(SOC_AM571x) || defined (SOC_AM572x) || defined (SOC_AM574x)
        boardCfg =   BOARD_INIT_MODULE_CLOCK;
        Board_init(boardCfg);
    #endif
    /*Pad configuration and PRCM enable*/
        padConfig_prcmEnable();
    
    #if defined(SOC_TDA3XX)
        AppUtils_defaultInit();
    #endif
        /* Set the UART Parameters */
        UART_init();
        params = gUserParams;
    
        gUartHandle = UART_open(UART_INSTANCE, &params);
        if(gUartHandle == NULL)
        {
            printf("\nError opening UART driver\n");
        }
    
        UART_write(gUartHandle,echoPrompt,sizeof(echoPrompt));
        UART_write(gUartHandle,echoPrompt1,sizeof(echoPrompt1));
    
        /* Modify the default SPI configurations if necessary */
        spi_initConfig();
    
        /* Do the necessary set up configurations for McSPI.*/
        SPI_init();
    
        /* Open MCSPI instance 1 driver */
        gSpiHandle = SPI_open(MCSPI_INSTANCE, &gSpiParams);
        if(gSpiHandle == NULL)
        {
            printf("\nError opening MCSPI driver\n");
        }
    
        McSPIInitializeBuffers();
    
        transaction.count = McSPI_DATA_COUNT;
        transaction.txBuf = gTxBuffer;
        transaction.rxBuf = gRxBuffer;
        SPI_transfer(gSpiHandle, &transaction);
    
        retVal = McSPIVerifyData();
    
        if(retVal != 0)
        {
            UART_write(gUartHandle,echoPrompt3,sizeof(echoPrompt3));
        }
        else
        {
            UART_write(gUartHandle,echoPrompt2,sizeof(echoPrompt2));
        }
    
        SPI_close(gSpiHandle);
    }
    
    static void McSPIInitializeBuffers(void)
    {
        uint32_t index = 0;
    
        for (index = 0; index < McSPI_DATA_COUNT; index++)
        {
            /* Initialize the gTxBuffer McSPI1 with a known pattern of data */
                gTxBuffer[index] = index;
            /* Initialize the gRxBuffer McSPI1 with 0 */
            gRxBuffer[index] = (uint32_t) 0;
        }
    }
    
    static int32_t McSPIVerifyData(void)
    {
        uint32_t index = 0;
        int32_t retVal = 0;
    
        for (index = 0; index < McSPI_DATA_COUNT; index++)
        {
            if(gRxBuffer[index] !=  gTxBuffer[index])
            {
                retVal = -1;
                break;
            }
        }
    
        return retVal;
    }
    /********************************* End Of File ******************************/
    

    I have below SPI3 registers settings:

    MCSPI_SYSCONFIG = 0x308

    MCSPI_SYSSTATUS = 0x1

    MCSPI_IRQSTATUS = 0x0

    MCSPI_IRQENABLE = 0x1

    MCSPI_MODULCTRL = 0x1

    MCSPI_CH0CONF = 0x380403FC

    MCSPI_CH0STAT = 0x2E

    MCSPI_CH0CTRL = 0x200

    MCSPI_TX0 = 0x31

    MCSPI_RX0 = 0x31


    I have also observed that only pin AF9 (spi3_d1) is used, and AE9 (spi3_d0) is not used in this test.

    Regards,
    Pavel

  • I have since updated my code to 06.01.00.08. I am still running into SPI 3 not working:

    Registry Dump

    MCSPI_SYSCONFIG: 308
    MCSPI_SYSSTATUS: 1
    MCSPI_IRQSTATUS: 0
    MCSPI_IRQENABLE: 0
    MCSPI_MODULCTRL: 1
    MCSPI_CH0CONF: 200403FC
    MCSPI_CH0STAT: 0
    MCSPI_CH0CTRL: 200
    MCSPI_TX0: 0
    MCSPI_RX0: 0

    Pinmux settings

         HW_WR_REG32(0x4A009800, 0x00000002); // Start SPI3 L4PER Clock Control
         HW_WR_REG32(CSL_MPU_CORE_PAD_IO_REGISTERS_REGS+CSL_CONTROL_CORE_PAD_IO_PAD_VOUT1_VSYNC,0x000C0008); // SPI3_SCLK (SPI3_IOSet_2)
         HW_WR_REG32(CSL_MPU_CORE_PAD_IO_REGISTERS_REGS+CSL_CONTROL_CORE_PAD_IO_PAD_VOUT1_DE,0x000C0008); // SPI3_D1 (SPI3_IOSet_2)
         HW_WR_REG32(CSL_MPU_CORE_PAD_IO_REGISTERS_REGS+CSL_CONTROL_CORE_PAD_IO_PAD_VOUT1_HSYNC,0x000C0008); // SPI3_D0 (SPI3_IOSet_2)
         HW_WR_REG32(CSL_MPU_CORE_PAD_IO_REGISTERS_REGS+CSL_CONTROL_CORE_PAD_IO_PAD_VOUT1_CLK,0x00060008); // SPI3_CS0 (SPI3_IOSet_2)

    Even running your code directly, the SPI3 IOSET 1 does not succeed the test for me. Do you know how this could be possible? I have a freshly flashed SD Card with a fresh install of Processor Linux and RTOS 06.01.00.08 using a fresh install of CCS 9.2.0.00013.

  • Andre,

    Andre Henriques said:

    Pinmux settings

        
         HW_WR_REG32(CSL_MPU_CORE_PAD_IO_REGISTERS_REGS+CSL_CONTROL_CORE_PAD_IO_PAD_VOUT1_VSYNC,0x000C0008); // SPI3_SCLK (SPI3_IOSet_2)
         HW_WR_REG32(CSL_MPU_CORE_PAD_IO_REGISTERS_REGS+CSL_CONTROL_CORE_PAD_IO_PAD_VOUT1_DE,0x000C0008); // SPI3_D1 (SPI3_IOSet_2)
         HW_WR_REG32(CSL_MPU_CORE_PAD_IO_REGISTERS_REGS+CSL_CONTROL_CORE_PAD_IO_PAD_VOUT1_HSYNC,0x000C0008); // SPI3_D0 (SPI3_IOSet_2)
         HW_WR_REG32(CSL_MPU_CORE_PAD_IO_REGISTERS_REGS+CSL_CONTROL_CORE_PAD_IO_PAD_VOUT1_CLK,0x00060008); // SPI3_CS0 (SPI3

    These pinmux is not the same as mine:

    //IOSET1

        HW_WR_REG32(CSL_MPU_CORE_PAD_IO_REGISTERS_REGS+CSL_CONTROL_CORE_PAD_IO_PAD_VIN1A_DE0,0x000C0008);
        HW_WR_REG32(CSL_MPU_CORE_PAD_IO_REGISTERS_REGS+CSL_CONTROL_CORE_PAD_IO_PAD_VIN1A_FLD0,0x000C0008); //d1
        HW_WR_REG32(CSL_MPU_CORE_PAD_IO_REGISTERS_REGS+CSL_CONTROL_CORE_PAD_IO_PAD_VIN1A_HSYNC0,0x000C0008); //d0
        HW_WR_REG32(CSL_MPU_CORE_PAD_IO_REGISTERS_REGS+CSL_CONTROL_CORE_PAD_IO_PAD_VIN1A_VSYNC0,0x00060008);

    Please align to my pinmux settings and try again.

    Regards,
    Pavel

  • Sorry for any misunderstanding. I tried this for both the SPI3 IOSet 2 settings which I shared along with your code which used SPI3 IOSet 1 as shown below.

        HW_WR_REG32(CSL_MPU_CORE_PAD_IO_REGISTERS_REGS+CSL_CONTROL_CORE_PAD_IO_PAD_VIN1A_DE0, 0x000C0008); // SPI3_SCLK (SPI3_IOSet_1)
        HW_WR_REG32(CSL_MPU_CORE_PAD_IO_REGISTERS_REGS+CSL_CONTROL_CORE_PAD_IO_PAD_VIN1A_FLD0,0x000C0008); // SPI3_D1 (SPI3_IOSet_1)
        HW_WR_REG32(CSL_MPU_CORE_PAD_IO_REGISTERS_REGS+CSL_CONTROL_CORE_PAD_IO_PAD_VIN1A_HSYNC0,0x000C0008); // SPI3_D0 (SPI3_IOSet_1)
        HW_WR_REG32(CSL_MPU_CORE_PAD_IO_REGISTERS_REGS+CSL_CONTROL_CORE_PAD_IO_PAD_VIN1A_VSYNC0,0x00060008); // SPI3_CS0 (SPI3_IOSet_1)

    In both scenarios, the SPI3 does not pass the McSPIVerifyData test. All other SPI peripherals do pass the test.

  • Andre,

    I do not see any difference in pin AF9 (VIN1A_FLD0.spi3_d1) between AM572x IDK and AM572x EVM. In both boards this pin is not connected. Can you attach a scope on these McSPI3 pins and monitor if there are any signals? You can compare with McSPI1, where you state that example is working fine.

    I will test also on my AM572x EVM board, rev A3A. For that purpose, could you please provide me below files:


    pdk_am57xx_1_0_16/packages/ti/drv/spi/example/mcspiLoopbackApp/am572x/armv7/bios/MCSPI_Loopback_evmAM572x_armExampleProject.txt
    pdk_am57xx_1_0_16/packages/ti/drv/spi/example/mcspiLoopbackApp/am572x/armv7/bios/mcspi_loopback_arm_evmAM572x.cfg
    pdk_am57xx_1_0_16/packages/ti/drv/spi/example/mcspiLoopbackApp/src/mcspiLoopbackApp.c

    Regards,
    Pavel

  • Andre,

    I was able to run this McSPI loopback test on evmAM572x SPI3 successful, I have below UART console output:

    McSPI Internal Loopback test app started
    The Mode of transfer is Interrupt Mode
    McSPI Data Transmission is successful

    I am testing on Cortex-A15 core, but should be the same for DSP C66x. I am using SPI3 IOSET1. I have modified below files. Please find attached.

    pdk_am57xx_1_0_16/packages/ti/drv/spi/example/mcspiLoopbackApp/am572x/armv7/bios/MCSPI_Loopback_evmAM572x_armExampleProject.txt

    pdk_am57xx_1_0_16/packages/ti/drv/spi/example/mcspiLoopbackApp/am572x/armv7/bios/mcspi_loopback_arm_evmAM572x.cfg

    pdk_am57xx_1_0_16/packages/ti/drv/spi/example/mcspiLoopbackApp/src/mcspiLoopbackApp.c

    -ccs.linkFile "PDK_INSTALL_PATH/ti/drv/spi/example/mcspiLoopbackApp/src/mcspiLoopbackApp.c"
    -ccs.linkFile "PDK_INSTALL_PATH/ti/drv/spi/example/mcspiLoopbackApp/am572x/armv7/bios/mcspi_loopback_arm_evmAM572x.cfg" 
    -ccs.setCompilerOptions "-c -mcpu=cortex-a15 -mtune=cortex-a15 -marm -mfloat-abi=hard -DSOC_AM572x -DevmAM572x -DMCSPI_MULT_CHANNEL -g -gstrict-dwarf -Wall -MMD -MP -I${PDK_INSTALL_PATH}/ti/drv/spi "  -rtsc.enableRtsc
    -ccs.setLinkerOptions " -lrdimon -lgcc -lm -lnosys -nostartfiles -static -Wl,--gc-sections "
    

    mcspi_loopback_arm_evmAM572x.cfg

     /*
     *  Copyright (C) 2015-2017 Texas Instruments Incorporated - http://www.ti.com/
     *
     *  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, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
     *  A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
     *  OWNER OR CONTRIBUTORS 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   mcspiLoopbackApp.c
     *
     *  \brief This file contains the application which demonstrates McSPI loopback
     *         which transfers some data pattern from data I/O signal & receives
     *         the data from same data I/O signal.
     *
     */
    
    /* ========================================================================== */
    /*                             Include Files                                  */
    /* ========================================================================== */
    /* XDCtools Header files */
    #include <xdc/std.h>
    #include <xdc/cfg/global.h>
    #include <xdc/runtime/Error.h>
    #include <xdc/runtime/System.h>
    
    /* BIOS Header files */
    #include <ti/sysbios/BIOS.h>
    #include <ti/sysbios/knl/Task.h>
    
    #include "stdint.h"
    #include <stdio.h>
    #include <ti/csl/example/utils/common/inc/app_utils.h>
    #include <ti/csl/soc.h>
    #include <ti/csl/hw_types.h>
    
    #include <ti/board/board.h>
    
    #include <ti/osal/osal.h>
    
    /* UART Header files */
    #include <ti/drv/uart/UART.h>
    
    /* SPI Header files */
    #include <ti/drv/spi/SPI.h>
    #include <ti/csl/csl_mcspi.h>
    #include <ti/drv/spi/soc/SPI_soc.h>
    #if defined SOC_AM335x
    #include "am335x_pinmux.h"
    #endif
    #if defined SOC_AM437x
    #include "am43xx_pinmux.h"
    #endif
    #if defined(SOC_AM335x) || defined(SOC_AM437x)
    #include "chipdb_defs.h"
    #endif
    
    /* ========================================================================== */
    /*                                 Macros                                     */
    /* ========================================================================== */
    
    #define McSPI_DATA_COUNT            50U // Data Count Transaction
    
    #if defined(SOC_AM571x) || defined (SOC_AM572x) || defined (SOC_AM574x)
    #define UART_INSTANCE 2
    #else
    #define UART_INSTANCE 0
    #endif
    
    #define MCSPI_INSTANCE 2
    
    /* ========================================================================== */
    /*                            Global Variables                                */
    /* ========================================================================== */
    uint8_t           gRxBuffer[McSPI_DATA_COUNT];
    uint8_t           gTxBuffer[McSPI_DATA_COUNT];
    
    UART_Handle gUartHandle;
    
    SPI_Handle gSpiHandle;
    
    /* UART parameters structure*/
    const UART_Params gUserParams = {
        UART_MODE_BLOCKING,     /* readMode */
        UART_MODE_BLOCKING,     /* writeMode */
        SemaphoreP_WAIT_FOREVER,/* readTimeout */
        SemaphoreP_WAIT_FOREVER,/* writeTimeout */
        NULL,                  /* readCallback */
        NULL,                 /* writeCallback */
        UART_RETURN_NEWLINE,  /* readReturnMode */
        UART_DATA_TEXT,       /* readDataMode */
        UART_DATA_TEXT,       /* writeDataMode */
        UART_ECHO_ON,         /* readEcho */
        115200,               /* baudRate */
        UART_LEN_8,           /* dataLength */
        UART_STOP_ONE,        /* stopBits */
        UART_PAR_NONE         /* parityType */
    };
    
    /* SPI parameters structure Master mode*/
    SPI_Params gSpiParams = {
        SPI_MODE_BLOCKING,  /* transferMode */
        SemaphoreP_WAIT_FOREVER,/* transferTimeout */
        NULL,               /* transferCallbackFxn */
        SPI_MASTER,         /* mode */
        1000000,            /* bitRate */
        8,                  /* dataSize */
        SPI_POL0_PHA0,      /* frameFormat */
        NULL                /* custom */
    };
    
    /* ========================================================================== */
    /*                          Function Declarations                             */
    /* ========================================================================== */
    static void McSPIInitializeBuffers(void);
    void padConfig_prcmEnable();
    void spi_test(UArg arg0, UArg arg1);
    static int32_t McSPIVerifyData(void);
    
    /* ========================================================================== */
    /*                          Function Definitions                              */
    /* ========================================================================== */
    void padConfig_prcmEnable()
    {
    #if defined (SOC_DRA72x) || (SOC_DRA75x) || defined (SOC_DRA78x)
        Board_initCfg boardCfg;
    
        boardCfg = BOARD_INIT_PINMUX_CONFIG |
            BOARD_INIT_MODULE_CLOCK;
    
        Board_init(boardCfg);
    #endif
        /* Loopback mode is not available for MCSPI. To test Loopback on McSPI,
         * Receive Bit is enabled on both Tx and Rx pins of McSPI
         */
    #if defined(SOC_AM571x) || defined (SOC_AM572x) || defined (SOC_AM574x)
        HW_WR_REG32(CSL_MPU_CORE_PAD_IO_REGISTERS_REGS+CSL_CONTROL_CORE_PAD_IO_PAD_UART2_CTSN, 0x00050002);
        HW_WR_REG32(CSL_MPU_CORE_PAD_IO_REGISTERS_REGS+CSL_CONTROL_CORE_PAD_IO_PAD_UART2_RTSN, 0x00010001);
        //HW_WR_REG32(CSL_MPU_CORE_PAD_IO_REGISTERS_REGS+CSL_CONTROL_CORE_PAD_IO_PAD_SPI1_SCLK,0x000C0000);
        //HW_WR_REG32(CSL_MPU_CORE_PAD_IO_REGISTERS_REGS+CSL_CONTROL_CORE_PAD_IO_PAD_SPI1_D1,0x000C0000);
        //HW_WR_REG32(CSL_MPU_CORE_PAD_IO_REGISTERS_REGS+CSL_CONTROL_CORE_PAD_IO_PAD_SPI1_D0,0x000C0000);
       // HW_WR_REG32(CSL_MPU_CORE_PAD_IO_REGISTERS_REGS+CSL_CONTROL_CORE_PAD_IO_PAD_SPI1_CS0,0x00060000);
    
        //IOSET1
    
            HW_WR_REG32(CSL_MPU_CORE_PAD_IO_REGISTERS_REGS+CSL_CONTROL_CORE_PAD_IO_PAD_VIN1A_DE0,0x000C0008);
            HW_WR_REG32(CSL_MPU_CORE_PAD_IO_REGISTERS_REGS+CSL_CONTROL_CORE_PAD_IO_PAD_VIN1A_FLD0,0x000C0008); //d1
            HW_WR_REG32(CSL_MPU_CORE_PAD_IO_REGISTERS_REGS+CSL_CONTROL_CORE_PAD_IO_PAD_VIN1A_HSYNC0,0x000C0008); //d0
            HW_WR_REG32(CSL_MPU_CORE_PAD_IO_REGISTERS_REGS+CSL_CONTROL_CORE_PAD_IO_PAD_VIN1A_VSYNC0,0x00060008);
    
            /*MCSPI3 prcm*/
                //CM_CORE__L4PER 0x4A009700
                //CM_L4PER_MCSPI3_CLKCTRL 0x100
                    HW_WR_REG32(0x4A009700 + 0x100, 0x02);
                    while (HW_RD_REG32(0x4A009700 + 0x100) !=
                            0x02U)
                        {
                            ;
                        }
    
    #if defined (_TMS320C6X)
        /*
         * AM57x DSP does not have a default Xbar connection for UART
         * interrupts, need to use a reserved IRQ Xbar instance for Xbar
         * interrupt configuration
         */
         /* Use reserved XBAR_INST_DSP1_IRQ_34 */
        CSL_xbarIrqConfigure(CSL_XBAR_IRQ_CPU_ID_DSP1, CSL_XBAR_INST_DSP1_IRQ_34, CSL_XBAR_UART3_IRQ);
    #endif
    #if defined (SOC_AM572x) || defined(SOC_AM574x)
        //HW_WR_REG32(CSL_MPU_CORE_PAD_IO_REGISTERS_REGS+CSL_CONTROL_CORE_PAD_IO_PAD_SPI1_CS1,0x00060000);
        HW_WR_REG32(CSL_MPU_CORE_PAD_IO_REGISTERS_REGS+CSL_CONTROL_CORE_PAD_IO_PAD_MMC3_DAT3,0x00060001);  //IOSET1
    #endif
    #endif
    #if defined (SOC_TDA2XX) || defined(SOC_TDA2PX) || defined (SOC_TDA2EX)
        /*Pad configurations */
        HW_WR_REG32(SOC_CORE_PAD_IO_REGISTERS_BASE+CTRL_CORE_PAD_UART1_RXD,0x00040000);
        HW_WR_REG32(SOC_CORE_PAD_IO_REGISTERS_BASE+CTRL_CORE_PAD_UART1_TXD,0x00040000);
        HW_WR_REG32(SOC_CORE_PAD_IO_REGISTERS_BASE+CTRL_CORE_PAD_SPI1_SCLK,0x000C0000);
        HW_WR_REG32(SOC_CORE_PAD_IO_REGISTERS_BASE+CTRL_CORE_PAD_SPI1_D1,0x000C0000);
        HW_WR_REG32(SOC_CORE_PAD_IO_REGISTERS_BASE+CTRL_CORE_PAD_SPI1_D0,0x000C0000);
        HW_WR_REG32(SOC_CORE_PAD_IO_REGISTERS_BASE+CTRL_CORE_PAD_SPI1_CS0,0x00060000);
    #if defined (SOC_TDA2XX) || defined(SOC_TDA2PX)
        HW_WR_REG32(SOC_CORE_PAD_IO_REGISTERS_BASE+CTRL_CORE_PAD_SPI1_CS1,0x00060000);
    #endif
        /* IPU1 Crossbar */
        CSL_xbarIrqConfigure(CSL_XBAR_IRQ_CPU_ID_IPU1, CSL_XBAR_INST_IPU1_IRQ_44, CSL_XBAR_UART1_IRQ);
    #endif
    #if defined(SOC_TDA3XX)
        /*MCSPI1 prcm*/
        HW_WR_REG32(SOC_L4PER_CM_CORE_BASE + CM_L4PER_MCSPI1_CLKCTRL, 0x02);
        while (HW_RD_REG32(SOC_L4PER_CM_CORE_BASE + CM_L4PER_MCSPI1_CLKCTRL) !=
                0x02U)
            {
                ;
            }
        HW_WR_REG32(SOC_CORE_PAD_IO_REGISTERS_BASE+CTRL_CORE_PAD_IO_UART1_RXD,0x00040000);
        HW_WR_REG32(SOC_CORE_PAD_IO_REGISTERS_BASE+CTRL_CORE_PAD_IO_UART1_TXD,0x00000000);
        HW_WR_REG32(SOC_CORE_PAD_IO_REGISTERS_BASE+CTRL_CORE_PAD_IO_SPI1_CS0,0x00040000);
        HW_WR_REG32(SOC_CORE_PAD_IO_REGISTERS_BASE+CTRL_CORE_PAD_IO_SPI1_SCLK,0x00040000);
        HW_WR_REG32(SOC_CORE_PAD_IO_REGISTERS_BASE+CTRL_CORE_PAD_IO_SPI1_D0,0x00040000);
        HW_WR_REG32(SOC_CORE_PAD_IO_REGISTERS_BASE+CTRL_CORE_PAD_IO_SPI1_D1,0x00040000);
    
        /* IPU1 crossbar */
    #if defined (__TI_ARM_V7M4__)
        CSL_xbarIrqConfigure(CSL_XBAR_IRQ_CPU_ID_IPU1, CSL_XBAR_INST_IPU1_IRQ_44, CSL_XBAR_UART1_IRQ);
    #elif defined(_TMS320C6X)
        CSL_xbarIrqConfigure(CSL_XBAR_IRQ_CPU_ID_DSP1, CSL_XBAR_INST_DSP1_IRQ_44, CSL_XBAR_UART1_IRQ);
    #endif
    #endif
    #if defined(SOC_AM335x) || defined(SOC_AM437x)
        uint32_t ctrlModBase;
    
        /* UART */
        ctrlModBase = CHIPDBBaseAddress(CHIPDB_MOD_ID_CONTROL_MODULE, UART_INSTANCE);
        HW_WR_REG32(ctrlModBase+PIN_UART0_TXD, PIN_MODE(0));
        HW_WR_REG32(ctrlModBase+PIN_UART0_RXD, PIN_MODE(0) | PIN_RX_ACTIVE);
        /* SPI0 */
        ctrlModBase = CHIPDBBaseAddress(CHIPDB_MOD_ID_CONTROL_MODULE, MCSPI_INSTANCE);
        HW_WR_REG32(ctrlModBase+PIN_SPI0_SCLK, PIN_MODE(0) | PIN_RX_ACTIVE);
        HW_WR_REG32(ctrlModBase+PIN_SPI0_D0, PIN_MODE(0) | PIN_RX_ACTIVE);
        HW_WR_REG32(ctrlModBase+PIN_SPI0_D1, PIN_MODE(0) | PIN_RX_ACTIVE);
        HW_WR_REG32(ctrlModBase+PIN_SPI0_CS0, PIN_MODE(0) | PIN_RX_ACTIVE);
    #endif
    }
    
    void spi_initConfig(void)
    {
        SPI_v1_HWAttrs spi_cfg;
    
        /* Get the default UART init configurations */
        SPI_socGetInitCfg(MCSPI_INSTANCE, &spi_cfg);
    
        /* Modify the default SPI configurations if necessary */
        spi_cfg.chnCfg[spi_cfg.chNum].dataLineCommMode = MCSPI_DATA_LINE_COMM_MODE_4;
    
        /* Set the default UART init configurations */
        SPI_socSetInitCfg(MCSPI_INSTANCE, &spi_cfg);
    }
    
    int main(void)
    {
        Task_Handle task;
        Error_Block eb;
    
        Error_init(&eb);
    
        task = Task_create(spi_test, NULL, &eb);
        if (task == NULL) {
            System_printf("Task_create() failed!\n");
            BIOS_exit(0);
        }
    
        /* Start BIOS */
        BIOS_start();
        return (0);
    }
    
    void spi_test(UArg arg0, UArg arg1)
    {
        UART_Params      params;
        int32_t retVal;
        SPI_Transaction transaction;
    #if defined(SOC_AM335x) || defined(SOC_AM437x) || defined(SOC_AM571x) || defined (SOC_AM572x) || defined (SOC_AM574x)
        Board_initCfg boardCfg;
    #endif
    
        char echoPrompt[] = "\nMcSPI Internal Loopback test app started";
        char echoPrompt1[] = "\nThe Mode of transfer is Interrupt Mode";
        char echoPrompt2[] = "\nMcSPI Data Transmission is successful";
        char echoPrompt3[] = "\nMcSPI Data Transmission is Failed";
    
    #if defined(SOC_AM335x) || defined(SOC_AM437x) || defined(SOC_AM571x) || defined (SOC_AM572x) || defined (SOC_AM574x)
        boardCfg =   BOARD_INIT_MODULE_CLOCK;
        Board_init(boardCfg);
    #endif
    /*Pad configuration and PRCM enable*/
        padConfig_prcmEnable();
    
    #if defined(SOC_TDA3XX)
        AppUtils_defaultInit();
    #endif
        /* Set the UART Parameters */
        UART_init();
        params = gUserParams;
    
        gUartHandle = UART_open(UART_INSTANCE, &params);
        if(gUartHandle == NULL)
        {
            printf("\nError opening UART driver\n");
        }
    
        UART_write(gUartHandle,echoPrompt,sizeof(echoPrompt));
        UART_write(gUartHandle,echoPrompt1,sizeof(echoPrompt1));
    
        /* Modify the default SPI configurations if necessary */
        spi_initConfig();
    
        /* Do the necessary set up configurations for McSPI.*/
        SPI_init();
    
        /* Open MCSPI instance 1 driver */
        gSpiHandle = SPI_open(MCSPI_INSTANCE, &gSpiParams);
        if(gSpiHandle == NULL)
        {
            printf("\nError opening MCSPI driver\n");
        }
    
        McSPIInitializeBuffers();
    
        transaction.count = McSPI_DATA_COUNT;
        transaction.txBuf = gTxBuffer;
        transaction.rxBuf = gRxBuffer;
        SPI_transfer(gSpiHandle, &transaction);
    
        retVal = McSPIVerifyData();
    
        if(retVal != 0)
        {
            UART_write(gUartHandle,echoPrompt3,sizeof(echoPrompt3));
        }
        else
        {
            UART_write(gUartHandle,echoPrompt2,sizeof(echoPrompt2));
        }
    
        SPI_close(gSpiHandle);
    }
    
    static void McSPIInitializeBuffers(void)
    {
        uint32_t index = 0;
    
        for (index = 0; index < McSPI_DATA_COUNT; index++)
        {
            /* Initialize the gTxBuffer McSPI1 with a known pattern of data */
                gTxBuffer[index] = index;
            /* Initialize the gRxBuffer McSPI1 with 0 */
            gRxBuffer[index] = (uint32_t) 0;
        }
    }
    
    static int32_t McSPIVerifyData(void)
    {
        uint32_t index = 0;
        int32_t retVal = 0;
    
        for (index = 0; index < McSPI_DATA_COUNT; index++)
        {
            if(gRxBuffer[index] !=  gTxBuffer[index])
            {
                retVal = -1;
                break;
            }
        }
    
        return retVal;
    }
    /********************************* End Of File ******************************/
    

    McSPI3 module register dump is:

    MCSPI_HL_REV = 0x4030120B

    MCSPI_HL_HWINFO = 0x11

    MCSPI_HL_SYSCONFIG = 0x4

    MCSPI_REVISION = 0x2B

    MCSPI_SYSCONFIG = 0x308

    MCSPI_SYSSTATUS = 0x1

    MCSPI_IRQSTATUS = 0x0

    MCSPI_IRQENABLE = 0x1

    MCSPI_MODULCTRL = 0x1

    MCSPI_WAKEUPENABLE = 0x0

    MCSPI_SYST = 0x0

    MCSPI_CH0CONF = 0x380403FC

    MCSPI_CH0STAT = 0x2E

    MCSPI_CH0CTRL = 0x200

    MCSPI_TX0 = 0x31

    MCSPI_RX0 = 0x31

    MCSPI_XFERLEVEL  = 0x151F

    MCSPI_DAFTX = 0x0

    MCSPI_DAFRX = 0x0

    I am using AM572x EVM rev A3A (GPEVM_AM572x) and USB 560M JTAG emulator (Blackhawk USB560-M Emulator)

    Make sure when you launch the selected configuration and then connect to CortexA15_0 core, you have successful messages in CCS  console.

    Regards,
    Pavel


    Regards,
    Pavel