cancel
Showing results for 
Search instead for 
Did you mean: 

STM32U599 SPI1 EOT flag not updating

desmond
Associate III

I am using `HAL_SPI_Transmit_IT()` API to transmits 6 frames. The TXP interrupt correctly fires and feeds the TXDR register however after feeding the last frame into TXDR the EOT never fires, actually no interrupt fire after the last frame is feed.

  • Frame Size: 9 bits
  • FiFo threshold: 1 
  • All the interrupts that were enabled remain enabled including the EOT. (EIR=0x328)
  • TSIZE: 6 (does not change)
  • SCLK: 125KHz
    • Source CLK to SPI: HSI (16MHz
    • Prescaler: 128
    • The system clock is running 160MHz

It's worth noting polling mode also failed because EOT isn't being set either.

In other drivers we use HAL_SPI_Receive_DMA() and it works as expected. 

I reviewed  the STHAL driver but I do not see anything obvious wrong.

What criteria, besides TSIZE, triggers the hardware to set the EOT flag?

15 REPLIES 15

Sorry, good question:
you configure SPI as 9bit Word Size, and you write to a 16bit FIFO (sound already like a "discrepancy", at least an issue to bear in mind).
Does it mean, every FIFO write will take just a 9bit word from it? (I am not sure - STM guys?)
Or: does it take 16bits (as 9 + 7bits) and waits for another word written for the remaining 11bits still missing? (another FIFO write needed)

I have never used 9bit Word Size (DATASIZE), to be honest. It is an unclear question for me as well:
"how is the 16bit FIFO taken to send 9bit words?"
Worst case: you have to shuffle the bits, because: 9bit words on a 16bit FIFO is never aligned. Maybe you have to "shuffle" bits so that you send 9 + 7 bits but on next word the remaining 2 + 9 + 5 bits and so on (maybe with dummy bits at the last FIFO write).

No idea how the 16bit FIFO "maps" to send 9bit words, and if it would end up and send (writing to FIFO) an "incomplete word", just to provide the remaining bits (and where to place the "remaining bits", potentially on LSB part?)

You could try: reshuffle the bits and assume: a 16bit FIFO will really result in shifting out 16bits. Do not assume as: writing 9bits via a 16bit word will just transmit 9bit (because Word Size is set to 9bit and FIFO entry should ignore 7bits).

Why do you need a 9bit word?
What happens on a scope?
Do you see that (N-1) x 9bits come out, just the last few bits are missing?

What is your waveform (compared to the expected bit transmission)?

If so, you might consider that FIFO as 16bit - sends 16bits via SPI. If you assume to provide for every 16bit FIFO entry just 9bits (because word size is 9bits) - but it fails - the assumption is potentially wrong.

Try to send the "smallest dominator", e.g. 9 x 16bits = 144bits which is now a "full complete set of bits" (matching with the 16bit FIFO entries).

I would assume: 16bit FIFO entries means 16bit out (not just 9 bits and ignoring bits written to FIFO). You can try different "assumptions" and see with a scope what happens.

I am sure, the SPI counts the number of bits to send, but with 9bit word size and 16bit FIFO there is a chance that just one FIFO entry is missing (at the end).
Check via scope what comes out (and what and how many bits are missing). If you miss bits on a scope - the EOT will not come (because SPI misses these bits as well).

desmond
Associate III

@STOne-32 
Can you please provide some assistance? I believe I may have bumped into a issue with your SOC. 

Solution:

When the SCLK signal is incorrectly routed to the GPIO block the EOT flag is not set.

Ensure you correctly routed the GPIO block to the SPI SCLK signal using the correct alternative function for the GPIO block.

Hi @desmond ,

 

Glad to see you fixed the problem observed . Let us know if an assistance is needed from our side .

Cheers,

STOne-32

TDK
Guru

> In other drivers we use HAL_SPI_Receive_DMA() and it works as expected. 

I mean, glad you solved it, but it's hard to see how other drivers are working if SCK isn't even hooked up.

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

They are isolated it's not the same pin, nor peripheral.