How to use different SPI_MASTER_Transmit modes per transaction?

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

cross mob
jamesk
Level 3
Level 3
First solution authored 5 replies posted 5 sign-ins

I am using the SPI to control a radio device.  Transactions are either configurations (reading/writing register addresses), or radio buffer commands (reading/writing a FIFO).

I would like to use direct transfer mode for commands and reading from the FIFO, and DMA mode for writing to the FIFO.

Is it possible to configure DAVE to enable both SPI_MASTER_DIRECT_TRANSMIT_MODE and SPI_MASTER_DMA_TRANSMIT_MODE and selectively initiate transfers using the desired mode?

When writing to the FIFO using DMA the clocked SPI IN data (rx_data) is don't care.

When reading to from the FIFO only the initial read command needs to be valid and OUT data bytes are don't care (i.e. 0xff).  For efficiency sake I would like to not have to fill a dummy data buffer but have the SPI automatically send the dummy byte for each clocked byte.

0 Likes
1 Solution
jamesk
Level 3
Level 3
First solution authored 5 replies posted 5 sign-ins

After additional trial and error I was able to get this working by eanbling Direct TX & RX and DMA TX.  I have no need for DMA RX so it is not enabled.

I modified the SPI_MASTER_Transmit() to only do direct mode and disabled the call to SPI_MASTER_StartTransmitDMA() which can be called directly when needing DMA transfer.

I also changed to use Frame End Mode (XMC_SPI_CH_EnableFEM) to keep the chip-select enabled between direct writes (using TBUF only and not FIFO) and DMA transfers.

View solution in original post

0 Likes
5 Replies
gkercheck
Level 1
Level 1
First like given First reply posted 5 sign-ins

Hi James,

I tried this and couldn't get it to work.  I configured the SPI Master for DMA using the Dave tool then tried to call the SPI primitives to do a direct transfer.  My use case was that  I had 3 SPI devices daisy chained to the same SPI bus.  Two of the devices required a time sensitive write so I tried to go "direct" to them.  

I don't remember exact details but I know the two modes could not be intermingled.  To really get this to work you'd probably need  to completely re-initialize the USIC channel for DMA or direct mode while your application was running.  In other words, the initialization that occurs during the typical "DAVE_Init()" call would have to be run when you switch modes.   For me, this wasn't worth the headache so I found a way for my time sensitive SPI devices to work with DMA.

Gary

0 Likes
jamesk
Level 3
Level 3
First solution authored 5 replies posted 5 sign-ins

Thanks Gary.

I experimented with this at one point as well with no success.  I was hoping someone actually figured this out or definitively says it's not possible.  The DAVE wrapper appears to simplify setup but limits the possible use cases.

I'm thinking to make this work I'd have use the XMCLib API directly.

0 Likes
Aashita_R
Moderator
Moderator
Moderator
50 likes received 100 solutions authored 250 replies posted

Hi @jamesk ,

Can you please let me know which device are you using? Also, can you let us know a little bit more about your application why are trying to move in between different transmit modes?

Best Regards,

Aashita

0 Likes

XMC4700

The application is a channel hopping wireless network where timing estimation for start of frame is important.  Most radio commands on the SPI are very short and using DMA to transmit them adds extra overhead.  However writing to buffer/fifo memory for the radio transmit buffer may be up to 2k bytes and using DMA for those are more optimal.

0 Likes
jamesk
Level 3
Level 3
First solution authored 5 replies posted 5 sign-ins

After additional trial and error I was able to get this working by eanbling Direct TX & RX and DMA TX.  I have no need for DMA RX so it is not enabled.

I modified the SPI_MASTER_Transmit() to only do direct mode and disabled the call to SPI_MASTER_StartTransmitDMA() which can be called directly when needing DMA transfer.

I also changed to use Frame End Mode (XMC_SPI_CH_EnableFEM) to keep the chip-select enabled between direct writes (using TBUF only and not FIFO) and DMA transfers.

0 Likes