cancel
Showing results for 
Search instead for 
Did you mean: 

STM32U5 Autonomous mode SPI for ADC interface

spear-firmware
Associate

I'm trying to interface a TI ADC with an STM32U575ZI or STMU545RE (same issue on both Nucleo boards).

The ADC has a "data ready" pin that needs to trigger a fixed-size transfer of 32bytes over SPI.  Given the overall sampling rate, only a few microseconds are available for overhead.  Seems like a natural fit for the autonomous mode + DMA features on the STM32U micros, but I can't seem to figure out how this is supposed to go together.

I can get one transfer going no problem, sometimes two, but something always errors out.  Currently getting a MODF flag, which makes no sense based on the documentation as the NSS system is set to "software" and always at 1.

Is there a document describing how the DMA and SPI modules interact under autonomous mode?  I'm clearly missing something important here.  Handshaking, what causes the TSIZE to reload the CTSIZE register, recommended DMA configs + trigger setups, anything?

Working on putting together an example for people to dissect, but this must surely be a common usecase?

Thanks for any input.

2 REPLIES 2
TDK
Super User

ADCs are all slightly different, even ADCs from the same manufacturer. Especially at higher speeds, they require very specific timings in order to meet transfer requirements.

Can it be done with a STM32U5 autonomously? Very likely yes. However, there is no one size fits all solution here. You will need to look at your specific ADC and see what data requirements it has and meet those.

Are you sure it's 32 bytes per transfer, not 32 bits? It's relatively straightforward to trigger a 32 bit transaction in response to something, such as a trigger edge. 32 bytes is also possible but requires considerably more work.

Including the ADC part number would help.

If you feel a post has answered your question, please click "Accept as Solution".

Sure. It's a TI ADS1178.  We're using a pair with fixed TDMA on a single SPI bus, so 16 channels @16bit each.  Hench 32 bytes.

Absolutely looking to do the considerably more work route, but I need a working example to work from.  Can get a single transfer no problem.  Can get continuous with DMA.  Can't get continuous 32byte transfers.

 

Here's the timing on the SPI / nDRDY line from the ADS1178 manual:

spearfirmware_0-1770756560060.png

Minimalist main.c and ioc attached.