Reply
Posts: 76
Registered: ‎12-19-2014

Wait on DMA transfer finished Happy Gecko

Hi

I want to transfer Data over the dma to the SPI. I act as SPI Master and I want to send 4 Byte on every transfer. The transfers are triggered right after another. So now I have the problem that only the first byte is send over spi and the other 3 Bytes are not send. For receiving from the SPI I use a dma interrupt is this ok? How can I get the whole 4 Bytes on the SPI ?

I start the transfer like this:

#define SPI_TX_BUFFER_SIZE 4 
DMA_ActivateBasic(
                        DMA_CHANNEL_SPI1_TX,
                        true,
                        false,
                        (void *) &SPI1->TXDATA,
                        (void *) &SPI1_TxBuffer[0],
                        SPI_TX_BUFFER_SIZE -1);

 

Posts: 241
Registered: ‎07-27-2016

Re: Wait on DMA transfer finished Happy Gecko

Hi @Sneaker1992,

 

Have you checked the AppNote for DMA? We have a software example showing SPI master for EFM32G which can be compared against your code to see if you have missed anything. You will have to make the following change to your code to send all 4 bytes - 

 

#define SPI_TX_BUFFER_SIZE 4 
DMA_ActivateBasic(
                        DMA_CHANNEL_SPI1_TX,
                        true,
                        false,
                        (void *) &SPI1->TXDATA,
                        (void *) &SPI1_TxBuffer,
                        SPI_TX_BUFFER_SIZE -1);

That way you are sending the entire TxBuffer and not just the first byte. For more information, please refer to the example code in the AppNote.  

 

Best,

 

Manasa