Possible SPI DMA bug in STM32K743IIK
- February 22, 2019
- 6 replies
- 1255 views
I've run across what looks like a bug in the STM32H743IIK (144pin BGA) related to SPI DMA. It is a very strange one, and you can see the history of this issue on the ChibiOS forums here:
http://www.chibios.com/forum/viewtopic.php?f=16&t=4140&start=80
I do not believe this issue matches any existing errata.
The issue is that for some very specific clock tree settings (which are seen as valid in STM32Cube), the result of a SPI DMA will interleave zero bytes between each valid output byte. So if you expect to get 0xaa 0xbb 0xcc in a SPI response from a SPI peripheral then in fact you will see 0x00 0xaa 0x00 0xbb 0x00 0xcc in the DMA receive memory.
I have only reproduced this on a board with a 16MHz HSE. I have two other boards, one with a 24MHz HSE (a LFQ part) and of course the Nuceo with a 8MHz HSE.
The critical setting that causes this issue is D2PRE2, which controls the APB2 peripheral and timer clocks. I've only seen the issue when this is set to DIV2. I attach the full STM32Cube config file to this issue.
If I change D2PRE2 to DIV1 then it all works perfectly, and all SPI buses handle DMA fine.
With DIV2 at least SPI buses 1 and 2 get the interleaved zero issue.
The bug was reproduced under ChibiOS 19.1-stable. I can provide a git repo with full source if needed.
Kind regards,
Andrew Tridgell
ArduPilot dev team
