Sep 21, 2020
06:15 AM
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Sep 21, 2020
06:15 AM
Hi,
I am setting up the QSPI comms as follows:
The code sends the first two bytes but doesn't send anything for the rest.
how do I fix this?
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?
Solved! Go to Solution.
Labels
- Tags:
- IFX
1 Solution
Sep 23, 2020
07:03 AM
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Sep 23, 2020
07:03 AM
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.
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.
8 Replies
Sep 21, 2020
07:13 AM
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Sep 21, 2020
07:13 AM
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) {};
while (IfxQspi_SpiMaster_getStatus(&spiChannel) == SpiIf_Status_busy) {};
Sep 21, 2020
08:18 AM
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Sep 21, 2020
08:18 AM
I tried it. It sends the first exchange then get stuck in the while loop forever
Sep 22, 2020
01:41 AM
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Sep 22, 2020
01:41 AM
What are doing your TX and RX interrupt?
They should call IfxQspi_SpiMaster_isrDmaTransmit(&spi); and IfxQspi_SpiMaster_isrDmaReceive(&spi);
They should call IfxQspi_SpiMaster_isrDmaTransmit(&spi); and IfxQspi_SpiMaster_isrDmaReceive(&spi);
Sep 22, 2020
01:50 AM
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Sep 22, 2020
01:50 AM
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
Sep 22, 2020
07:16 AM
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Sep 22, 2020
07:16 AM
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.
Sep 22, 2020
07:54 AM
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Sep 22, 2020
07:54 AM
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?
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);
Sep 23, 2020
07:03 AM
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Sep 23, 2020
07:03 AM
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.
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.
Sep 23, 2020
07:52 AM
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Sep 23, 2020
07:52 AM
Thanks. Worked like a charm.