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.

TMS570 SPI in client mode using DMA

Other Parts Discussed in Thread: HALCOGEN, TMS570LS3137

Hello,

Does anyone have TMS570 micro example code where micro is SPI client and transmitting data use functionality DMA? Ideally will be if logic is for SPI compatible mode.

Cheers,

Stefan 

  • Stefan,

    HalCoGen ships with an example "example_mibspiDma.c".  I know you wanted compatibiltiy mode, but I think if you get this example to work then you'll be able to dial it back down to compatibility mode.

    I'm not aware of a canned example for compatibility mode.  The main difference though would be the source/destination addresses move from MibSPI RAM to the SPIDAT and SPIBUF registers.  And the format of these registers (bit field assignment) is different.  The DMA part itself I don't think will have too much to adjust.

     

  • Yes, I am aware of this example but what is really troubles me is micro to work as SPI slave. I was unable to find anything useful for this. So far:

    1. I was able to run this micro in SPI compatible mode as slave but it can not send data with enough speed. It only works when I put dummy loop and delay micro that is master SPI.

    2. I relay on DMA to increase speed but I was unable to run it so far.

    3. I am testing it now in multiple buffer mode but is not behaving as expect. Again I TMS is as slave. It seems Transfer groups are useful when micros is master. 

  • Stefan,

    Ok, I understand a little more now.   SPI slave doesn't have all the features that master mode does. 

    Are you using a chip select to select the SPI in slave mode?  This is the first thing that usually trips people up - you have to use CS0 to select the SPI when it's a slave.  The other CS are not functional in slave mode.

    If you want please post your SPI register settings after it's configured and I'll look through them to see if I spot anything.

     

  • Anthony,

    This explains why most of my attempts failed. I am using CS3. However on SPI1/slave/compatible mode is working but not with speed that I expect.

    Can you send me simple code or just several rows how to setup DMA that must work? I will put on my project and try. I am using Keil project Blinky on MCBTMS570 board.

    Stefan

  • Anthony,

     HalCodeGenerator in file reg_spi.h doesn't generate all register for SPI.

    typedef volatile struct spiBase
    {
        uint32  GCR0;                 /**< 0x0000: Global Control 0 */
        uint32  GCR1;                 /**< 0x0004: Global Control 1 */    
        uint32  INT0;                 /**< 0x0008: Interrupt Register */    
        uint32  LVL;                  /**< 0x000C: Interrupt Level */
        uint32  FLG;                  /**< 0x0010: Interrupt flags */        
        uint32  PC0;                  /**< 0x0014: Function Pin Enable */
        uint32  PC1;                  /**< 0x0018: Pin Direction */
        uint32  PC2;                  /**< 0x001C: Pin Input Latch */
        uint32  PC3;                  /**< 0x0020: Pin Output Latch */
        uint32  PC4;                  /**< 0x0024: Output Pin Set */
        uint32  PC5;                  /**< 0x0028: Output Pin Clr */
        uint32  PC6;                  /**< 0x002C: Open Drain Output Enable */
        uint32  PC7;                  /**< 0x0030: Pullup/Pulldown Disable */
        uint32  PC8;                  /**< 0x0034: Pullup/Pulldown Selection */
        uint32  DAT0;                 /**< 0x0038: Transmit Data */
        uint32  DAT1;                 /**< 0x003C: Transmit Data with Format and Chip Select */
        uint32  BUF;                  /**< 0x0040: Receive Buffer */
        uint32  EMU;                  /**< 0x0044: Emulation Receive Buffer */
        uint32  DELAY;                /**< 0x0048: Delays */
        uint32  DEF;                  /**< 0x004C: Default Chip Select */
        uint32  FMT0;                 /**< 0x0050: Data Format 0 */
        uint32  FMT1;                 /**< 0x0054: Data Format 1 */
        uint32  FMT2;                 /**< 0x0058: Data Format 2 */
        uint32  FMT3;                 /**< 0x005C: Data Format 3 */
        uint32  INTVECT0;             /**< 0x0060: Interrupt Vector 0 */
        uint32  INTVECT1;             /**< 0x0064: Interrupt Vector 1 */
        uint32  RESERVED[51U];        /**< 0x0068 to 0x0130: Reserved */    
        uint32  IOLPKTSTCR;           /**< 0x0134: IO loopback */
    } spiBASE_t;

    There is no DMA related registers. I am confused. Is it possible TMS570 not to work with DMA in compatible mode at all.

    Stefan

  • Stefan,

    I don't have a SPI slave, compatibility mode, using DMA example to send.  I can ask around among colleagues to see if anyone has one but there may not be.  

    HalCoGen doesn't have a DMA driver yet.  But in compatibility mode there are not any registers missing from the list above except perhaps the modulo register and that's relevant for only MibSPIP.

    The DMA registers that you see in the MibSPI chapter and in fact all the registers above MIBSPIE are for "Mib" mode when the MIB unit is enabled.

    In compatibility mode, the DMA request is controlled by bit 16 (DMAREQEN) of SPIINT0.

     

  • Anthony,

    Is there a list with relation between request line number and  actual  device. For SPI0 TX i have found that request line is 0, for RX is 1.


    Cheers,

    Stefan

  • Stefan,

    The table of DMA requests is in the datasheet for the device (not the TRM).

    The DMA requests are shared among several peripherals with an "OR" function so for each DMA request you might see three peripherals listed on a single line.   This means that you have to make sure only one peripheral of the three is being used with DMA at a time,  since having 2 peripherals making requests to the same DMA channel simultaneously is something the DMA can't sort out.   When I say 'at the same time' I mean without changing the DMA configuration.  For example, you could change from SPI to another peripheral sharing the same DMA line in an applicaiton but it would have to be a state change where the CPU gets in and reconfigures the peripherals as well as the DMA control packets to point to the new peripheral.    It's not something the DMA can manage on it's own or change on the fly.

     

  • Stefan,

    I've created a basic test code to demonstrate the usage of DMA and SPI Slave.

    In this example, a master MIBSPI (MIBPSI1) is configured to send 4 16bits word to a slave device using multibuffer mode. CS_0 on master side is used to select the slave SPI. CS hold is used to keep CS0 active low during the transmission of the 4 16bits data.

    On the slave side, DMA is configured as following:

    8311.Frame_Transfer.pptx

    The code for this project is available 1057.SPI_Master_Slave_DMA.zip

    For this demo to work, is is necessary to interconnect the SPI3 with MIBSPI.

    The following lines are necessary:

    MIBSPI1SOMI to SPI3SOMI
    MIBSPI1SIMO to SPI3SIMO
    MIBSPI1CLK to SPI3CLK
    MIBSPI1CS_0 to SPI3CS_0

    Please have a try and let me know if this is useful.

  • Jean-Marc,

    I am trying to figure out how to use SPI2 to send a byte to an external device (an Arduino at the moment) but the Arduino doesn't see CS0 change.

    I noticed in your sample program that you do this:

    spiDAT1_t dataconfig1_t;

    dataconfig1_t.CS_HOLD = TRUE;
    dataconfig1_t.WDEL = TRUE;
    dataconfig1_t.DFSEL = SPI_FMT_0;
    dataconfig1_t.CSNR = 0xFE;

    Which is what I pass to this:

    spiTransmitData(spiREG2, &dataconfig1_t, 1, &dataValue);

    but in your sample code you are not using dataconfig1_t at all.

    I am not seeing CS0 go to ground (and the Arduino isn't seeing the chip select).  I've been trying all kinds of different setting on SPI2.   I'm surprised I can't seem to find a simple example for using SPI (not MibSPI). I am using a TMS570LS3137 HDK.

  • I just realized that SPI2 is connected to the SD Card on the HDK - I seem to be making progress using SPI5 instead... :-)
  • Hi Thomas,

    You are right, we have tried this sample code and it doesn't work because CS0 is not well configured. The right configuration in Halcogen is the following one. 

     .

    Alain