Skip to main content
rich.g.williams
Senior
Oct 19, 2026 11:28 PM UTC
Solved

STM32H5E5 SPI slave: TX shift register width and Tx FIFO to Tx shift register transfer width

I'm using SPI1 on an STM32H5E5 in slave mode, with DSIZE = 32 bits, TSIZE=0 and `FTHLV` configured for four 32-bit frames.

I'm trying to understand the internal transmit pipeline more precisely.

Is the internal TX shift-register width (in bits) or transfer granularity documented anywhere for the STM32H5E5 please?

What is the effective width of the TX shift register, and how does data move from the byte-organised TX FIFO into it?

I would appreciate clarification of the internal TX FIFO to TX shift register data flow please?

For a 16 byte Tx FIFO, assume the TX FIFO is pre filled and full, as transmission begins, data transfers from the TX FIFO into the TX shift register so the Tx FIFO has new space immediately. So the TX FIFO becomes empty before the RX FIFO becomes full. What I'm trying to discover is how many SCLK pulses occur between TX FIFO empty and RX FIFO full. I expected it to be around 32 SCLK's (32 bit) but its closer to 8 SCLK's closer to one byte rather than one word.

Any information explaining this much appreciated.

rich.g.williams
rich.g.williamsBest answer
Senior
Oct 23, 2026 3:20 PM UTC

​@FBL 

In a spirit of Friday afternoon camaraderie - your expert has missed this.

Its actually useful for you ST people to think about this. So please get you expert to have a read through my explanation on Bill’s Notes  billsnotes.co.uk

Yes I thought it would be a 32 bit shift register but it is not.

Starting from:-

  • slave mode
  • full TX FIFO (SPI1 16 bytes)
  • empty RX FIFO
  • when clocking starts TX and RX are tied in that clocking is common to both
  • TX FIFO becomes empty exactly 6.5 SCLK before RX FIFO becomes full

 

So it is not “a delay of 32 bit frame “or 32 SCLK pulses” between these events”

It is a delay of 6.5 SCLK pulses between these events.

Seriously this method I outline could be useful to ST customers.

Please encourage your expert to read my writeup, he or she will have a real eureka moment as the penny drops.

Have a good weekend

Richard

Bill's Notes

13 replies

ST Technical Moderator
Oct 20, 2026 9:58 AM UTC

Hi ​@rich.g.williams 

The reference manual does not document the internal TX shift register width or the exact mechanism by which data moves from the TX FIFO into the shift register. FIFO servicing is based on the configured packet threshold and the occupancy flags. Also, accesses smaller than the configured data size are not permitted.
So, SCLK pulses does not establish the TX shift register width or the FIFO granularity.

To give better visibility on the answered topics, please click on "Best answer" on the reply which solved your issue or answered your question.Best regards,FBL
rich.g.williams
Senior
Oct 20, 2026 10:33 AM UTC

​@FBL Thank you for your reply.

“FIFO servicing is based on the configured packet threshold and the occupancy flags.”  Yes and in my case where I am using DSIZE = 32 bits, TSIZE=0, FTHLV for four frames, in slave mode and a FIFO size of 16 bytes the TX FIFO can only be empty or full.

Assuming a start position where the TX FIFO is full and the RX FIFO is empty, subsequent SCLK clocking empirically always results in the TX FIFO becoming empty before the RX FIFO becomes full so I conclude some bits have been loaded into the TX shift register from the TX FIFO before RX FIFO becomes full.

Logically the TX pipleline must be TX FIFO plus TX shift register width, whereas the RX pipeline is only the RX FIFO.

This is why I would like to be able to attribute a width to the TX shift register. Maybe you could ask this question beyond what is documented in the reference manual please.

Bill's Notes
ST Technical Moderator
Oct 21, 2026 2:31 PM UTC

Hi ​@rich.g.williams 

In my understanding, observing the TX FIFO become empty before the RX FIFO reaches its packet threshold does not reflect the need to determine TX shift-register width. It shows only that the two FIFO status conditions occur at different points in the data flow.

To give better visibility on the answered topics, please click on "Best answer" on the reply which solved your issue or answered your question.Best regards,FBL
rich.g.williams
Senior
Oct 21, 2026 6:38 PM UTC

Hi ​@FBL 

The reasoning is this,  normally the FIFO is seen as giving elasticity, as long as it is serviced before it runs out all is well.

I asked the question (after writing the code) “what’s the longest time the FIFO (both TX and RX) can remain un-serviced measured in SCLK pulses. Its useful where execution can drop a “big packet” into the fifo, go away and return just in time to repeat, the biggest packet is the size of the FIFO, 16-bytes for SPI1. It was possible to sustain continuous duplex SPI by doing this.

I have written this up on my website here:-

 Using the STM32H5E5 SPI1 for continuous duplex comms

Thanks for looking into this.

 

Bill's Notes
TDK
Oct 21, 2026 6:47 PM UTC

> what’s the longest time the FIFO (both TX and RX) can remain un-serviced measured in SCLK pulses

It isn’t measured in SCK pulses, but by how much data can be packed in the FIFOs. With 8-bit data word, this is equal to 16 bytes or 8 bytes depending on the SPI instances. Subtract one more word if UDR is configured to trigger early and you don’t want that to happen.

The SPI has so much configurability. You can program it to sustain continuous operation in many ways. Re-fill the FIFO when it’s half empty, for example. This is very doable.

"If you feel a post has answered your question, please click ""Accept as Solution""."
rich.g.williams
Senior
Oct 21, 2026 7:47 PM UTC

​@TDK 

“It isn’t measured in SCK pulses”  Yes it is measured in SCLK pulses or bytes in the FIFO - for what I have explained.

For my “slave mode” case described in detail here Using the STM32H5E5 SPI1 for continuous duplex comms its exact and I summarise as follows:-

For SPI1 with 16 byte TX FIFO from the moment you fill it to the brim it contains 16 x 8 bits = 128 bits. every SCLK pulse shifts out 1 bit.  but some of those bits are in the shift register so the TX FIFO runs dry after less than 128 SCLK and TXP is asserted just before the TX FIFO runs dry, refilling it immediately and quickly avoids triggering UDR error.

For SPI1 RX FIFO its different, assuming the FIFO is empty before clocking starts, then the RX FIFO becomes completely full after exactly 128 SCLK pulses (or 16 bytes).

“You can program it to sustain continuous operation in many ways” yes you can - but the method I explain of dropping a 16 byte packet into the TX FIFO (and fetching a 16 byte packet from the RX FIFO) gives the longest possible time between service intervals, and its exactly 128 SCLK pulses with a service time of about 7 SCLK’s

I am talking about continuous full duplex SPI at SCLK frequency sustained over large blocks or even indefinitely - without DMA or interrupts.

Bill's Notes
ST Technical Moderator
Oct 22, 2026 12:33 PM UTC

Sorry ​@rich.g.williams but the link you shared is not accessible on my end. Can you summarize the test results in here?

To give better visibility on the answered topics, please click on "Best answer" on the reply which solved your issue or answered your question.Best regards,FBL
rich.g.williams
Senior
Oct 22, 2026 12:56 PM UTC

​@FBL Just type into your browser billsnotes.co.uk and you will quickly find it 

 

Bill's Notes
ST Technical Moderator
Oct 23, 2026 1:30 PM UTC

Hi ​@rich.g.williams 

I got the answer from our expert : 

In full duplex, the TX and RX FIFOs are independent. The TX FIFO can become empty as its final 32 bit frame moves into the TX shift register; that frame still requires 32 SCLK pulses to finish transmitting.

The RX FIFO receives the corresponding data only as it is shifted IN, so its status changes after reception completes.

Thus, a delay of 32 bit frame “or 32 SCLK pulses” between these events is consistent with the transmit pipeline.

edit :The observed interval between TXP and RXP is specific to the configuration and flag timing you describe; it should not be generalized as a 32 SCLK delay neither 6.5 SCLK delay

To give better visibility on the answered topics, please click on "Best answer" on the reply which solved your issue or answered your question.Best regards,FBL
rich.g.williams
rich.g.williamsAuthorBest answer
Senior
Oct 23, 2026 3:20 PM UTC

​@FBL 

In a spirit of Friday afternoon camaraderie - your expert has missed this.

Its actually useful for you ST people to think about this. So please get you expert to have a read through my explanation on Bill’s Notes  billsnotes.co.uk

Yes I thought it would be a 32 bit shift register but it is not.

Starting from:-

  • slave mode
  • full TX FIFO (SPI1 16 bytes)
  • empty RX FIFO
  • when clocking starts TX and RX are tied in that clocking is common to both
  • TX FIFO becomes empty exactly 6.5 SCLK before RX FIFO becomes full

 

So it is not “a delay of 32 bit frame “or 32 SCLK pulses” between these events”

It is a delay of 6.5 SCLK pulses between these events.

Seriously this method I outline could be useful to ST customers.

Please encourage your expert to read my writeup, he or she will have a real eureka moment as the penny drops.

Have a good weekend

Richard

Bill's Notes