TC4xx promo banner Banner_Aurix_Competition Banner_AURIX_Security-Solution Banner_AURIX_Safety_Products ShieldBuddy TC275 Banner_AURIX_DevelopmentStudio


+ Reply to Thread
Results 1 to 9 of 9

Thread: TLF35584 QSPI comms with ILLD drivers bytes not sending

  1. #1
    New Member New Member Fernandes is on a distinguished road
    Join Date
    Aug 2020
    Posts
    35
    Points
    222.5

    TLF35584 QSPI comms with ILLD drivers bytes not sending

    Hi,

    I am setting up the QSPI comms as follows:

    Code:
    // create module config
       IfxQspi_SpiMaster_Config spiMasterConfig;
       IfxQspi_SpiMaster_initModuleConfig(&spiMasterConfig, &TLF_QSPI_MODULE);
    
       // set the desired mode and maximum baudrate
       spiMasterConfig.base.mode             = SpiIf_Mode_master;
       spiMasterConfig.base.maximumBaudrate  = 10000000;
    
       // ISR priorities and interrupt target (with Dma usage)
       spiMasterConfig.base.txPriority       = TLF_DMA_QSPIPRIO_TX;
       spiMasterConfig.base.rxPriority       = TLF_DMA_QSPIPRIO_RX;
       spiMasterConfig.base.erPriority       = TLF_DMA_QSPIPRIO_ER;
    
       // dma configuration.
       spiMasterConfig.dma.txDmaChannelId = TLF_DMA_CHN_TX_ID;
       spiMasterConfig.dma.rxDmaChannelId = TLF_DMA_CHN_RX_ID;
       spiMasterConfig.dma.useDma = 1;
    
       // pin configuration
       const IfxQspi_SpiMaster_Pins PINS = {
           &TLF_QSPI_SCLK_PIN, IfxPort_OutputMode_pushPull,     // SCLK
           &TLF_QSPI_MOSI_PIN, IfxPort_OutputMode_pushPull,     // MTSR
           &TLF_QSPI_MISO_PIN, IfxPort_InputMode_pullDown,      // MRST
           IfxPort_PadDriver_cmosAutomotiveSpeed3               // pad driver mode
       };
       spiMasterConfig.pins = &PINS;
    
       // initialize module
       IfxQspi_SpiMaster_initModule(&spi, &spiMasterConfig);
    
       /* After the module has been initialized, one or more SPI channels can be 
       configured. Each channel has a dedicated select line.*/
    
       // create channel config
       IfxQspi_SpiMaster_ChannelConfig spiMasterChannelConfig;
       IfxQspi_SpiMaster_initChannelConfig(&spiMasterChannelConfig, &spi);
    
       // set the baudrate for this channel
       spiMasterChannelConfig.base.baudrate = 5000000;
       // select pin configuration
       const IfxQspi_SpiMaster_Output SLSOUTPUT = {
           &TLF_QSPI_SLSO_PIN,
           IfxPort_OutputMode_pushPull,
           IfxPort_PadDriver_cmosAutomotiveSpeed1
       };
    
       spiMasterChannelConfig.sls.output = SLSOUTPUT;
       spiMasterChannelConfig.mode = IfxQspi_SpiMaster_Mode_longContinuous; // Select Long Continuous Mode
    
       // initialize channel
       IfxQspi_SpiMaster_initChannel(&spiChannel, &spiMasterChannelConfig);
    
       // Sending and Receiving a data stream:
       spiMasterTxBuffer = 0x8756;
       // send/receive new stream
       IfxQspi_SpiMaster_exchange(&spiChannel, &spiMasterTxBuffer, &spiMasterRxBuffer, TLF_CMD_BUFFER_SIZE);
       // IfxQspi_SpiMaster_isrDmaReceive(&spi);
       // IfxQspi_SpiMaster_isrDmaTransmit(&spi);
       // IfxQspi_clearAllEventFlags(&TLF_QSPI_MODULE);
       // wait until transfer of previous data stream is finished
       // while( IfxQspi_SpiMaster_getStatus(&spiChannel) == SpiIf_Status_busy ) {;}
       
       spiMasterTxBuffer = 0x87DE;
       // send/receive new stream
       IfxQspi_SpiMaster_exchange(&spiChannel, &spiMasterTxBuffer, &spiMasterRxBuffer, TLF_CMD_BUFFER_SIZE);
       // IfxQspi_SpiMaster_isrDmaReceive(&spi);
       // IfxQspi_SpiMaster_isrDmaTransmit(&spi);
       // IfxQspi_clearAllEventFlags(&TLF_QSPI_MODULE);
       // wait until transfer of previous data stream is finished
       // while( IfxQspi_SpiMaster_getStatus(&spiChannel) == SpiIf_Status_busy ) {;}
       
       spiMasterTxBuffer = 0x86AD;
       // send/receive new stream
       IfxQspi_SpiMaster_exchange(&spiChannel, &spiMasterTxBuffer, &spiMasterRxBuffer, TLF_CMD_BUFFER_SIZE);
       // IfxQspi_SpiMaster_isrDmaReceive(&spi);
       // IfxQspi_SpiMaster_isrDmaTransmit(&spi);
       // IfxQspi_clearAllEventFlags(&TLF_QSPI_MODULE);
       // wait until transfer of previous data stream is finished
       // while( IfxQspi_SpiMaster_getStatus(&spiChannel) == SpiIf_Status_busy ){;}
       
       spiMasterTxBuffer = 0x8625;
       // send/receive new stream
       IfxQspi_SpiMaster_exchange(&spiChannel, &spiMasterTxBuffer, &spiMasterRxBuffer, TLF_CMD_BUFFER_SIZE);
       // IfxQspi_SpiMaster_isrDmaReceive(&spi);
       // IfxQspi_SpiMaster_isrDmaTransmit(&spi);
       // IfxQspi_clearAllEventFlags(&TLF_QSPI_MODULE);
       // wait until transfer of previous data stream is finished
       // while( IfxQspi_SpiMaster_getStatus(&spiChannel) == SpiIf_Status_busy ){;}
    The code sends the first two bytes but doesn't send anything for the rest.
    how do I fix this?

  2. #2
    Advanced Advanced
    Infineon Employee
    Infineon Employee
    MoD is on a distinguished road
    Join Date
    Feb 2012
    Location
    Munich
    Posts
    261
    Points
    5249.375
    Between two call of IfxQspi_SpiMaster_exchange you must wait until the previous action is finished. Add before or after ...exchange e.g.:
    while (IfxQspi_SpiMaster_getStatus(&spiChannel) == SpiIf_Status_busy) {};
    The views expressed here are my personal opinions, have not been reviewed or authorized by Infineon and do not necessarily represent the views of Infineon.

  3. #3
    New Member New Member Fernandes is on a distinguished road
    Join Date
    Aug 2020
    Posts
    35
    Points
    222.5
    I tried it. It sends the first exchange then get stuck in the while loop forever

  4. #4
    Advanced Advanced
    Infineon Employee
    Infineon Employee
    MoD is on a distinguished road
    Join Date
    Feb 2012
    Location
    Munich
    Posts
    261
    Points
    5249.375
    What are doing your TX and RX interrupt?
    They should call IfxQspi_SpiMaster_isrDmaTransmit(&spi); and IfxQspi_SpiMaster_isrDmaReceive(&spi);
    The views expressed here are my personal opinions, have not been reviewed or authorized by Infineon and do not necessarily represent the views of Infineon.

  5. #5
    New Member New Member Fernandes is on a distinguished road
    Join Date
    Aug 2020
    Posts
    35
    Points
    222.5
    I have not set up interrupts. I am trying to use it without any interrupts (and possibly without dma) as if I was polling it

  6. #6
    Advanced Advanced
    Infineon Employee
    Infineon Employee
    MoD is on a distinguished road
    Join Date
    Feb 2012
    Location
    Munich
    Posts
    261
    Points
    5249.375
    The interrupts are needed to detect the end of transmit and receive. Please see file IfxQspi_SpiMaster.h in the iLLD, at the beginning of this files there are examples in the comments with DMA and without DMA.
    The views expressed here are my personal opinions, have not been reviewed or authorized by Infineon and do not necessarily represent the views of Infineon.

  7. #7
    New Member New Member Fernandes is on a distinguished road
    Join Date
    Aug 2020
    Posts
    35
    Points
    222.5
    Okay. I used those examples to get this far.

    Here is my configuration. It works but I need to wait till for a time period before the next exchange. Is there a flag I can use to check instead of waiting?

    Code:
    #define TLF_CMD_BUFFER_SIZE      1       /* SPI Buffer size; 1 16bit command*/
    #define TLF_DMA_CHN_TX_ID        IfxDma_ChannelId_1
    #define TLF_DMA_CHN_RX_ID        IfxDma_ChannelId_2
    
    #define TLF_DMA_QSPIPRIO_TX      1
    #define TLF_DMA_QSPIPRIO_RX      2
    #define TLF_DMA_QSPIPRIO_ER      0x30
    static IfxQspi_SpiMaster spi;
    static IfxQspi_SpiMaster_Channel spiChannel;
    
    // create module config
       IfxQspi_SpiMaster_Config spiMasterConfig;
       IfxQspi_SpiMaster_initModuleConfig(&spiMasterConfig, &TLF_QSPI_MODULE);
    
       // set the desired mode and maximum baudrate
       spiMasterConfig.base.mode             = SpiIf_Mode_master;
       spiMasterConfig.base.maximumBaudrate  = 10000000;
    
       // ISR priorities and interrupt target (with Dma usage)
       spiMasterConfig.base.txPriority       = TLF_DMA_QSPIPRIO_TX;
       spiMasterConfig.base.rxPriority       = TLF_DMA_QSPIPRIO_RX;
       spiMasterConfig.base.erPriority       = TLF_DMA_QSPIPRIO_ER;
    
       // dma configuration.
       spiMasterConfig.dma.txDmaChannelId = TLF_DMA_CHN_TX_ID;
       spiMasterConfig.dma.rxDmaChannelId = TLF_DMA_CHN_RX_ID;
       spiMasterConfig.dma.useDma = 1;
    
       // pin configuration
       const IfxQspi_SpiMaster_Pins PINS = 
          {
          &TLF_QSPI_SCLK_PIN, IfxPort_OutputMode_pushPull,     // SCLK
          &TLF_QSPI_MOSI_PIN, IfxPort_OutputMode_pushPull,     // MTSR
          &TLF_QSPI_MISO_PIN, IfxPort_InputMode_pullDown,      // MRST
          IfxPort_PadDriver_cmosAutomotiveSpeed3               // pad driver mode
          };
       spiMasterConfig.pins = &PINS;
    
       // initialize module
       IfxQspi_SpiMaster_initModule(&spi, &spiMasterConfig);
    
       /* After the module has been initialized, one or more SPI channels can be 
       configured. Each channel has a dedicated select line.*/
    
       // create channel config
       IfxQspi_SpiMaster_ChannelConfig spiMasterChannelConfig;
       IfxQspi_SpiMaster_initChannelConfig(&spiMasterChannelConfig, &spi);
    
       // set the baudrate for this channel
       spiMasterChannelConfig.base.baudrate = 5000000;
       // select pin configuration
       const IfxQspi_SpiMaster_Output SLSOUTPUT = 
          {
          &TLF_QSPI_SLSO_PIN,
          IfxPort_OutputMode_pushPull,
          IfxPort_PadDriver_cmosAutomotiveSpeed1
          };
    
       spiMasterChannelConfig.sls.output = SLSOUTPUT;
       spiMasterChannelConfig.mode = IfxQspi_SpiMaster_Mode_long;
       // spiMasterChannelConfig.mode = IfxQspi_SpiMaster_Mode_longContinuous;
    
       // initialize channel
       IfxQspi_SpiMaster_initChannel(&spiChannel, &spiMasterChannelConfig);
    
    static volatile uint32_t x, y, z, p;
    
       // perform exchange of data
       IfxQspi_SpiMaster_exchange(&spiChannel, &TxData[0], &RxData, TLF_CMD_BUFFER_SIZE);
       
       // wait until transfer of previous data stream is finished
       for (x = 0; x < 10; x++)
          {
          for (y = 0; y < 10; y++)
             {
             z = p;
             p = z*3;
             }
          }
       IfxQspi_SpiMaster_isrDmaReceive(&spi);

  8. #8
    Advanced Advanced
    Infineon Employee
    Infineon Employee
    MoD is on a distinguished road
    Join Date
    Feb 2012
    Location
    Munich
    Posts
    261
    Points
    5249.375
    You test this:
    do
    {
    IfxQspi_SpiMaster_isrDmaReceive(&spi);
    } while (IfxQspi_SpiMaster_getStatus(&spi) == SpiIf_Status_busy);

    if there was in interrupt on the DMA channel (end of receive) then function isrDmaReceive will clear this interrupt and set the status to SpiIf_Status_busy otherwise the function do nothing.
    The views expressed here are my personal opinions, have not been reviewed or authorized by Infineon and do not necessarily represent the views of Infineon.

  9. #9
    New Member New Member Fernandes is on a distinguished road
    Join Date
    Aug 2020
    Posts
    35
    Points
    222.5
    Thanks. Worked like a charm.

+ Reply to Thread
Disclaimer

All content and materials on this site are provided “as is“. Infineon makes no warranties or representations with regard to this content and these materials of any kind, whether express or implied, including without limitation, warranties or representations of merchantability, fitness for a particular purpose, title and non-infringement of any third party intellectual property right. No license, whether express or implied, is granted by Infineon. Use of the information on this site may require a license from a third party, or a license from Infineon.


Infineon accepts no liability for the content and materials on this site being accurate, complete or up- to-date or for the contents of external links. Infineon distances itself expressly from the contents of the linked pages, over the structure of which Infineon has no control.


Content on this site may contain or be subject to specific guidelines or limitations on use. All postings and use of the content on this site are subject to the Usage Terms of the site; third parties using this content agree to abide by any limitations or guidelines and to comply with the Usage Terms of this site. Infineon reserves the right to make corrections, deletions, modifications, enhancements, improvements and other changes to the content and materials, its products, programs and services at any time or to move or discontinue any content, products, programs, or services without notice.