2017-09-11 01:03 AM
My tool chain is STM32F429 with STM32CubeMX, and MDK.
I'm using SPI4 to read data from a ADC, though I configure SPI4 as 'duplex master', I only need to read from it. When not using DMA, I call 'HAL_SPI_Receive()' to read data. And there are clock output on SPI_SCK pin. But when I configure it to use DMA (DMA2 Stream 0, P2M, PSIZE = 16bit, MSIZE = 16bit), and after calling '
HAL_SPI_Receive_DMA'
nothing output on SPI_SCK pin. As known, DMA only start after data received, so I don't think the problem is in my DMA configuration. The key point is why there is no clock output on SPI_SCK pin.
It seems
'HAL_SPI_Receive()' will send some dummy bytes to slave and at the same time read back some data. Won't 'HAL_SPI_Receive_DMA()' send dummy bytes?
#willitblend #stm32f4 #spi #dma2017-09-11 04:22 AM
An SPI Master would need to be generating output traffic for the clock to be generated, being a symmetrical bus.
DMA for TX and RX are independent, I'd expect you'd need to set both of them up, and have a block of dummy data if that's what you need to send.
2017-09-11 08:24 PM
Yes, I must enable DMA for both Tx and Rx, and call 'HAL_SPI_TransmitReceive_DMA()'. Then the clocks will appear on SCK pin.
What misleading is '
HAL_SPI_Receive()' will send dummy bytes, but the 'DMA' version won't!!!!
2017-09-27 03:27 AM
I have the same problem. To use HAL_'SPI_Receive_DMA()' I have to configure also DMA for TX. Moreover 'SPI_Transmit_DMA()' does not work at all. I get HAL_'SPI_ERROR_DMA'. Problem only occurs on SPI4 when I used SPI5, DMA work correctly.
2017-09-27 10:22 AM
2018-06-22 09:00 AM
Hi, I am also facing same problem by seeing your post
==>
An SPI Master would need to be generating output traffic for the clock to be generated, being a symmetrical bus.
DMA for TX and RX are independent, I'd expect you'd need to set both of them up, and have a block of dummy data if that's what you need to send.
<==
It is resulting in hardfault have any one faced this problem.
2018-06-22 10:18 AM
>>It is resulting in hardfault have any one faced this problem.
Yes, usually by not touching memory addresses that I shouldn't. Identify what your faulting code is doing.