13183 views|19 replies

89

Posts

0

Resources
The OP
 

About the SPI BUG in the HAL library (V1.1.0) of STM32H7 [Copy link]

 
I've been playing with stm32h743xi recently, and I feel that the chip is quite powerful. During the SPI test, I found that calling the HAL_SPI_Transmit function to send multiple bytes has not been successful, and only the first byte is sent. After debugging, I found that the hal library did not clear the TXTF flag after sending a byte successfully, resulting in subsequent unsuccessful transmission. Solution: Add /* check TXTF flag */ after line 652 if (__HAL_SPI_GET_FLAG(hspi, SPI_FLAG_TXTF)) { __HAL_SPI_CLEAR_TXTFFLAG(hspi); } I hope it will be helpful to those who debug this later.
This post is from stm32/stm8

Latest reply

Yes, time is tight.  Details Published on 2018-1-29 09:19
 

483

Posts

0

Resources
2
 
Like this
This post is from stm32/stm8
 
 

180

Posts

0

Resources
3
 
There should be a column on the bugs of the HAL library
This post is from stm32/stm8
 
 

3

Posts

0

Resources
4
 
Encountered the same problem
This post is from stm32/stm8
 
 
 

89

Posts

0

Resources
5
 
Here is another pitfall. In the SPI driver of the H7 hal library, when calling the HAL_SPI_TransmitReceive function, the received data will be wrong. For example, it should receive 01 01 64... but actually receives 01 00 01 64... The reason for the problem is that the TXTF flag is cleared too early. The original cycle of sending and receiving data is to write the sent data to TXDR first, then clear TXTF, and then read the RXDR register data. It should be to write the sent data to TXDR first, then read the RXDR register data, and then clear TXTF. Otherwise, the read data will always be wrong.
This post is from stm32/stm8

Comments

You are wrong. If it is receiving, you must use RXNE to mark it. Sending empty does not mean that the reception is completed, because the transmission is buffered.  Details Published on 2018-1-9 15:54
 
 
 

4005

Posts

0

Resources
6
 
dige posted on 2018-1-9 15:32 Let me fill in another hole. In the spi driver of the H7 hal library, calling the HAL_SPI_TransmitReceive function will result in an error in the received data. For example,...
You are wrong. If it is receiving, you must use the RXNE mark. Sending empty does not mean that the reception is completed, because the transmission is buffered.
This post is from stm32/stm8

Comments

The result of the test here is that if the TXTF flag is cleared, the RXNE flag is also cleared, and there is a problem with receiving data.  Details Published on 2018-1-9 16:22
 
 
 

89

Posts

0

Resources
7
 
huo_hu posted on 2018-1-9 15:54 You are wrong. If it is receiving, you must use the RXNE mark. Sending empty does not mean that the reception is completed, because the transmission is buffered.
The test result here is that if the TXTF flag is cleared, the RXNE mark is also cleared, and there is a problem with receiving data.
This post is from stm32/stm8

Comments

There are slight time differences here, and what you see through the simulator may not be correct.  Details Published on 2018-1-9 21:28
 
 
 

4005

Posts

0

Resources
8
 
dige posted on 2018-1-9 16:22 The test result here shows that if the TXTF flag is cleared, the RXNE flag is also cleared, and there is a problem with the received data.
There is a slight time difference, and what you see through the simulator may not be correct.
This post is from stm32/stm8

Comments

How can I modify the receiver? The test is to read and write ferroelectric memory through SPI. Currently, the order is adjusted, and the ferroelectric reading is normal. If it is not adjusted, the reading will be wrong as described before. I don't know if there is a more reasonable modification.  Details Published on 2018-1-9 22:26
 
 
 

89

Posts

0

Resources
9
 
huo_hu posted on 2018-1-9 21:28 There is a slight time difference here, and what you see through the simulator may not be correct.
May I ask how to modify the reception? The test is to read and write ferroelectric memory through SPI. At present, the order is adjusted, and the ferroelectric reading is normal. If it is not adjusted, the reading will be wrong as mentioned before. I don't know if there is a more reasonable modification.
This post is from stm32/stm8

Comments

OK, as long as it works, I haven't succeeded in using the F405 SPI receive/transmit interrupt. It worked with f103 before, but not with f4.  Details Published on 2018-1-10 10:56
 
 
 

4005

Posts

0

Resources
10
 
dige posted on 2018-1-9 22:26 Can you tell me how to modify the reception? The test is to read and write ferroelectric memory through SPI. At present, the order is adjusted, and the ferroelectric reading is normal. If it is not adjusted, the reading...
OK, it can be used. I haven't succeeded in using F405 SPI transceiver interrupt. It worked with f103 before, but not with f4.
This post is from stm32/stm8
 
 
 

3

Posts

0

Resources
11
 
huo_hu posted on 2018-1-10 10:56 OK, as long as it works, I haven't succeeded in using F405 SPI transceiver interrupt. It worked with f103 before, but not with f4.
The SPI architecture of H7 has changed, and it is different from the previous model
This post is from stm32/stm8
 
 
 

1903

Posts

0

Resources
12
 
I suggest you don't use the library, it's rubbish, it's more practical to configure the registers directly, everything is under control
This post is from stm32/stm8
 
 
 

3

Posts

0

Resources
13
 
Have you tested the H7 SPI DMA?
This post is from stm32/stm8

Comments

After testing, the SPI receiving DMA has the following problems: first, change the receiving fifo threshold from 08 to SPI_FIFO_THRESHOLD_01DATA, otherwise part of the received data will always be stored in the fifo; second, shield the following code, otherwise the received data length will be incorrect. I hope it helps you. // if ((hspi  Details Published on 2018-1-24 16:40
 
 
 

89

Posts

0

Resources
14
 
Xiao Q Yumi posted on 2018-1-17 18:59 Have you tested the DMA of H7 SPI?
I have tested it. The SPI receiving DMA has the following problems. First, change the receiving fifo threshold from 08 to SPI_FIFO_THRESHOLD_01DATA, otherwise part of the received data will always be stored in the fifo. Second, shield the following code, otherwise the length of the received data will be incorrect. I hope it helps you. // if ((hspi->RxXferCount & 0x1U) == 0x0U) // { // hspi->RxXferCount = hspi->RxXferCount >> 1U; // } // else // { // hspi->RxXferCount = (hspi->RxXferCount >> 1U) + 1U; // }
This post is from stm32/stm8
 
 
 

1w

Posts

16

Resources
15
 
Should report to ST company: time:
This post is from stm32/stm8
 
Personal signaturehttp://shop34182318.taobao.com/
https://shop436095304.taobao.com/?spm=a230r.7195193.1997079397.37.69fe60dfT705yr
 
 

1903

Posts

0

Resources
16
 
The st library is an abyss, a bottomless pit. I hate it. I only use it when time is tight. I usually write it myself and never use the library.
This post is from stm32/stm8

Comments

That would be very tiring.  Details Published on 2018-1-29 08:24
That would be very tiring.  Details Published on 2018-1-26 20:48
 
 
 

4005

Posts

0

Resources
17
 
star_66666 posted on 2018-1-26 15:07 The st library is an abyss, a bottomless pit. It is very annoying. I only use it when time is tight. I usually write it myself and never use the library
It will be very tiring.
This post is from stm32/stm8
 
 
 

1903

Posts

0

Resources
18
 
I am a little tired, but I am happy.
This post is from stm32/stm8
 
 
 

89

Posts

0

Resources
19
 
star_66666 posted on 2018-1-26 15:07 The library of st is an abyss, a bottomless pit, very annoying, only used when time is tight, usually write it yourself, never use the library
Writing it yourself and using the library each have their own advantages, H7 is just out, the library has more problems, it should be perfected and mature later. I have no choice, I have to rush to release the product, I found a lot of pitfalls, but now everything is smooth.
This post is from stm32/stm8
 
 
 

1903

Posts

0

Resources
20
 
Yes, time is tight.
This post is from stm32/stm8
 
 
 

Guess Your Favourite
Just looking around
Find a datasheet?

EEWorld Datasheet Technical Support

EEWorld
subscription
account

EEWorld
service
account

Automotive
development
circle

Copyright © 2005-2024 EEWORLD.com.cn, Inc. All rights reserved 京B2-20211791 京ICP备10001474号-1 电信业务审批[2006]字第258号函 京公网安备 11010802033920号
快速回复 返回顶部 Return list