cancel
Showing results for 
Search instead for 
Did you mean: 

SPI TX trouble on F4

jwoolston
Associate II
Posted on August 14, 2014 at 19:39

I have an SPI setup using DMA transfers that works for a while, and then reaches a point where the data that is passed to the DMA transfer is not what is sent over the SPI lines. Typically, I am able to successfully make a dozen or so transfers in each direction, then at some point (it varies) when I try and perform a transmit as an SPI slave, the only byte which is sent is the last byte which was received.

If I check the DMA transfer setup with the following code:

/* Enable the Tx DMA Stream */
printf(''Starting DMA TX Transfer for count: %'' PRIu16 '' From Address %p\n\r'', hspi->TxXferCount, hspi->pTxBuffPtr);
HAL_DMA_Start_IT(hspi->hdmatx, (uint32_t) hspi->pTxBuffPtr, (uint32_t) &hspi->Instance->DR, hspi->TxXferCount);
printf(''DMA Source: %p\tSPI DR: 0x%02'' PRIX8 ''\n\r'', hspi->hdmatx->Instance->M0AR, hspi->Instance->DR);

I get exactly what I would expect. The DMA source is correct, and the DR contains the first byte of the buffer to be sent, however, when I examine the transmission with a logic probe, The transfer consists of the last received byte, for the length of the transfer. Perhaps even more interesting is that the transfer complete for the DMA is never raised. The DMA has the highest priority preemption interrupt in the system with the exception of SYSTICK. Does anyone have any advice on where or how I might determine what is causing this? I'm confused because it all works fine for a while and then suddenly fails like this.
3 REPLIES 3
jwoolston
Associate II
Posted on August 16, 2014 at 00:51

Can anyone suggest how I might go about determining what the cause of this is? I have gone through the HAL drivers and they appear to follow the procedure laid out in the reference manual. Additionally, it does work for small buffers, and then I try this large buffer and have this problem.

jwoolston
Associate II
Posted on August 16, 2014 at 01:07

I have also tried this with the blocking TX method with the same result.

Posted on October 09, 2014 at 10:54

Hi,

Could you specify the SPI mode used in your example? Please try to use the SPI full duplex mode. If you are using the master 1 line Rx with Slave 1 Line Tx, the master clock is generated just after enabling the SPI, so that you should start the Slave transmit before the master receive for this mode. 

PS: I think you have a synchronization issue.

Regards,

Heisenberg.