2025-08-29 8:46 AM - edited 2025-08-29 8:47 AM
Each time I enable SPI, it works fine.
However, whenever I include USART, SPI freezes, and this issue affects multiple chips I've tested.
SPI and USART both work well individually.
The problem seems to stem from CubeMX, which doesn't generate the code correctly.
Coding directly in Keil or CubeIDE might solve the issue, but it's time-consuming—which is exactly why we use CubeMX in the first place.
Does anyone know if this could be a simple issue, like an interrupt conflict or shared resource problem?
I looked at bunch of options like making sure the interrupt priority for USART and SPI is different.
Making sure SPI does not kick in while USART (DMA) is still processing data, ect
It's definitely a CubeMX code generation issue.
Any suggestions on how to make SPI and USART work together?
2025-09-18 3:03 PM
It took a while to figure out what was going on. The system didn’t freeze immediately—it ran for about half an hour, which initially made it seem like DMA was working fine. However, after repeated runs, I eventually concluded that DMA was the root of the problem.
Feel free to update the thread based on this observation. There might be a fix in the code, but I haven’t found one yet. The chip has limited resources. Under heavy load, it will eventually freeze. You hook up more that it can handle. I do not have much to say, like a good advice for everybody.
2025-09-18 5:00 PM
DMA does not have a lifespan after which it stops working. This is a code bug somewhere. If you don't show the code, there's not much we can help with here.