2014-06-02 05:32 AM
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)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)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-tx2014-06-02 05:58 AM
> Do you have any idea where this can come from?
No, because we don't know how do you generate the chipselect signal. JW2014-06-02 06:09 AM
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
2014-06-02 06:16 AM
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