cancel
Showing results for 
Search instead for 
Did you mean: 

SPI DMA vs Normal SPI, delay CS after transmission

mzetek9
Associate
Posted on June 02, 2014 at 14:32

Hi,

We are working on STM32F417.

We are getting a ''problem'' (if it is a problem) with the SPI through DMA.

The function which send data through SPI is selecting the device at the beggining and unselecting it after the transfer.

With a normal SPI transmission we get the ''unselect device'' right after the transmission is completed, for any baud rate prescaler. (see printscreen with a baud rate prescaler of 8)

0690X000006057kQAA.png

Now, if I am using the same baud rate prescaler and the same data are send. We are getting a delay after the transfer is complete. The fact is that the duration of the chip select is the same as for Normal SPI transfer. (see printscreen with also a baudrate prescaler of 8)

0690X000006057uQAA.png

For a baud rate prescaler of 4, the DMA transfer is faster (sure it is) and so the delay is longer but almost the same as a baudrateprescaler of 8.

Also, with less data to send, the chip select keep the same duration in DMA mode.

Do you have any idea where this can come from?

Thank you,

Marc

#dma-spi-tx
3 REPLIES 3
Posted on June 02, 2014 at 14:58

> Do you have any idea where this can come from?

No, because we don't know how do you generate the chipselect signal.

JW

mzetek9
Associate
Posted on June 02, 2014 at 15:09

True, sorry about that.

We are working with FreeRTOS.

We are taking a semaphore that the DMA Handler gives.

{

 

........

 

 

DMA_SetCurrDataCounter(DMA_TX, __u8_DataTotalLength);

 

DMA_Cmd(DMA_TX, ENABLE);

 

xSemaphoreTake(_x_SemaphoreSendingOK, portMAX_DELAY);

 

  

 

  vHILWIZNET_UnselectDevice(); // Unselect device each time an operation is done

 

}

The Unselect function just set a I/O.

And this is the DMA handler:

void DMA1_Stream5_IRQHandler(void)

 

{  

 

  signed portBASE_TYPE  __x_HigherPriorityTaskWoken = pdFALSE;

 

  

 

  if (DMA_GetITStatus(DMA_TX, DMA_IT_TCIF5))

 

  {

 

  /* Clear DMA Stream Transfer Complete interrupt pending bit */

 

    DMA_ClearITPendingBit(DMA_TX, DMA_IT_TCIF5);

 

xSemaphoreGiveFromISR(_x_SemaphoreSendingOK,&__x_HigherPriorityTaskWoken);

 

    portEND_SWITCHING_ISR(__x_HigherPriorityTaskWoken);

 

  }

 

}

Marc

Posted on June 02, 2014 at 15:16

It's then a task-switching problem in the OS, isn't it? Can't you toggle the chipselect pin directly in the DMA ISR? Sorry, I don't RTOS, so can't comment further.

JW