UART getting stuck in TX mode on resuming from sleep mode.
Hello @Tilen MAJERLE and everyone else,
So, I have written firmware to work on the STM32L476RG microcontroller. A part of it is not working properly.
I activated DMA on the SPI(SPI1) and UART(UART5) communication channels. I use the SPI to communicate with a camera, while I use the UART to communicate with a Bluetooth module (HM-11). Previously I was using the polling method to communicate, and it worked. But I wanted to optimize it, so I switched to DMA. It did shave off some seconds off the image download time.
When I switched to DMA, I noticed that when the system went to sleep, I could still wake it up via Bluetooth, but it will not respond to commands after waking it up from SLEEP MODE. I used the debugging tool and found that it was getting stuck here:

What could be making it get stuck in that position? The system is supposed to transmit a coded message via Bluetooth when it wakes up that's why it gets to the highlighted code in the above picture.
You can also take a look at the priorities assigned to the interrupts below:

DMA2 belongs to UART5 and DMA1 belongs to SPI1.
Let me know what other information you will need.
Thanks in advance.
