2015-10-23 08:42 AM
Hello,
I've got an STM32F746 here and I want to use SPI1, SPI2 and SPI4 in parallel with DMA. For each, one DMA channel pushes data into DR by a timer request, and another listens for a SPI_RX and forwards to memory. However, exactly the same code works flawlessly with SPI2 and SPI4 but fails to trigger RX DMA on SPI1. To investigate further, I've send some test data via each SPI using the following code (having DMA stream not yet enabled): while (!(hdl->pSpi->SR & SPI_SR_TXE)); //wait for the transmit buffer to become empty hdl->pSpi->DR = data; where hdl->pSpi points to the SPI_TypeDef under test. On a breakpoint shortly after the send I hald and use RegisterView to investigate, having only CR1, CR2 and SR enabled (to avoid Register viewer clearing the DR by reading it). It turns out that for SPI2 and SPI4 RXNE in SR gets asserted (which I would expect in the duplex SPI setting), but not for SPI1. CRC, BIDIMODE etc are disabled, MSTR is set, and CR1 and CR2 are exactly the same for all SPIs! Logic analyzer also shows that SPI1 sends the data correctly, as SPI2 and 4 do, with the correct MOSI, CLK and NSS pulses. It just would not consider any data received after that! It would also not trigger any error interrupt. GPIO seems properly configured to PA4-PA7 with alternative function AF5 selected. PA4 and PA5 are not 5V-tolerant, but the MISO does not exceed 3.3V either. Is there any possible GPIO misconfiguration or electrical failure mode that would lead an SPI into leaving RXEN reset after a transfer? I'm starting to consider a faulty chip, but it would be a very unlikely fault... #spi #dma #stmm32f7 #nss2015-10-23 02:05 PM
I must say first, that I have nil experience with 'F7.
You've put NSS into tags, but did not mention it in the text... please elaborate. Try to set it to soft and inactive. Also, what are the CR1 and CR2 settings you've mentioned, and how exactly are the GPIO set? Does changing the GPIO ''speed'' settings (mainly of SCK) change anything? Does changing the mode (CPOL/CPHA) have any influence on things? JW2015-10-24 05:53 AM
2015-10-24 12:25 PM
Hey,
GPIOA Pins are configured as alternative function, AF5_SPI2 (using the HAL driver, register values seem right). Setting them to the alternative function should, as far as I understand, imply configuring them as inputs and outputs accordingly. I've thought an electrical short might prevent the NSS from being asserted and force invalidate the transmission, but the logic analyzer shows a correct pulse. SSM (software slave select) is disabled, SSI, as far as register view shows, is always set. @JW GPIOAs are set to AF5_SPI2 function (as cube generated). I'll post the contents of CR1 and 2 and attempt the things you've suggested monday. I'd be surprised to have anything wrong with them as SPI2 and SPI4 are configured in exactly the same way and do work properly..2015-10-24 01:50 PM
2015-10-25 10:26 AM
> I've thought an electrical short might prevent the NSS from being asserted and force invalidate the transmission, but the logic analyzer shows a correct pulse.
Ah, so you have turned it to output and pulsing? Then it's not likely it's the culprit. And what are exactly the symptoms? What happens if you don't play with DMA, only read it in a simple loop? JW2015-10-26 02:03 AM
Yep, it's on output.
I've added a screenshot as an attachement. ad_configure happens after HAL_SPI_Init has run but before the DMA inits have. It uses ad_transmit_once(), visible on top of the sourcecode to transmit synchronously. The breakpoint on HAL_Delay is triggered: you can see the register values on the right. (SPI1 DR is not read by the register view to avoid clearing). For SPI2 and SPI4 the RXNE is set at this point, but not for SPI1. ________________ Attachments : spi1_problem.png : https://st--c.eu10.content.force.com/sfc/dist/version/download/?oid=00Db0000000YtG6&ids=0680X000006I0hW&d=%2Fa%2F0X0000000bcc%2FGfmuyace1AJNAgLyJnp8u6zkUVJlnMrenU63HeRpMF0&asPdf=false2015-10-26 03:35 AM
If DMA is running, it reads the DR thus clears RXNE even if you ''stop'' execution through breakpoint or single-step.
Stop/don't start DMA and observe SPI. JW2015-10-26 05:23 AM
DMA is not enabled(nor even initialized) at the point of the test I've shown in the previous post.
2015-10-26 06:34 AM
Did you consider the Rx FIFO? Is there any change if you set SPI1->CR2.FRXTH?
I repeat I have no experience with 'F7 nor the newer SPIs with FIFO in other STM32 models. JW