TLF35584 QSPI comms with ILLD drivers bytes not sending

Announcements

From sunburn to sun earn – we’ve got the power! Watch our #poweringgreen videos now.

Tip / Sign in to post questions, reply, level up, and achieve exciting badges. Know more

cross mob
User20083
Level 3
Level 3
25 replies posted 10 replies posted 5 replies posted
Hi,

I am setting up the QSPI comms as follows:

// 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?
0 Likes
1 Solution
MoD
Employee
Employee
50 likes received 500 replies posted 100 solutions authored
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.

View solution in original post

0 Likes
8 Replies
MoD
Employee
Employee
50 likes received 500 replies posted 100 solutions authored
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) {};
0 Likes
User20083
Level 3
Level 3
25 replies posted 10 replies posted 5 replies posted
I tried it. It sends the first exchange then get stuck in the while loop forever
0 Likes
MoD
Employee
Employee
50 likes received 500 replies posted 100 solutions authored
What are doing your TX and RX interrupt?
They should call IfxQspi_SpiMaster_isrDmaTransmit(&spi); and IfxQspi_SpiMaster_isrDmaReceive(&spi);
0 Likes
User20083
Level 3
Level 3
25 replies posted 10 replies posted 5 replies posted
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
0 Likes
MoD
Employee
Employee
50 likes received 500 replies posted 100 solutions authored
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.
0 Likes
User20083
Level 3
Level 3
25 replies posted 10 replies posted 5 replies posted
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?



#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);
0 Likes
MoD
Employee
Employee
50 likes received 500 replies posted 100 solutions authored
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.
0 Likes
User20083
Level 3
Level 3
25 replies posted 10 replies posted 5 replies posted
Thanks. Worked like a charm.
0 Likes