2025-02-05 02:13 AM
Hello,
I'm experiencing strange intermittent failures using STM32U575ZIQ using SPI and related DMA.
MCU SPI setup: slave Rx-only mode, with slave select HW signal.
SPI from the master (AD7768 ADC) shows 4MHz clock active all the time (even when there is no data), and slave select signal is active all the time too except for one "inactive" pulse just before the first data transmission bit is issued (i.e. there is an active start transition just before the first bit). The data burst from this master is 64bytes long (16 x 32-bit words), and one burst is sent every 250us (4kHz activity).
As the slave select and data clock are still active after the last data bit is over, I have to stop the SPI (for not reading empty data) and re-start it to have it ready listening for the next "slave select" active transition. I'm using HAL routines "HAL_SPI_DeInit" and "HAL_SPI_Init" to do this. I'm transferring the data from the SPI to the MCU memory using DMA 32-bytes bursts, and this works fine quite often (the program runs for 30s, sometimes more, sometimes less). Sometimes a problem occurs after one single data (1 x 32-bit word) is received and the DMA transfer complete TCF flag triggers an interrupt much too early (as 16 x 32-bit words are expected before TCF).
Questions:
1. Is there a risk to have the SPI activity starting (once every now and then) when enabling the MCU SPI while master is clocking and slave select is active (although there was no active transition on slave select)?
2. The disabling of SPI and re-enablig using "HAL_SPI_DeInit" and "HAL_SPI_Init" is very slow. Is there a faster and cleaner way to do this?
3. new topic: I'm using LPUART as well to forward the received data... I couldn't operate it using consecutive DMA instructions "HAL_UART_Transmit_DMA", and had to "enable" LPUART each time using "HAL_UART_Init" before next "HAL_UART_Transmit_DMA" instruction. Any recommendation on how I could/should do this in a clean way?