Posted on June 08, 2017 at 10:58The original post was too long to process during our migration. Please click on the attachment to read the original post.
further investigation pointed towards a strange behaviour:
the aforementioned code is working great if it's compiled with -O0, 1, 2, 3, g, s but HAL_UART_RECEIVE_DMA fails to set the uart peripheral in UART_STATE_BUSY_RX when the gcc optimisation is settled to -Of, hence the issue i have enlightened in the previous post.
It that a known behaivour of Hal_Uart, there's a solution the this issue?
Issues related to variables modified in interrupts and having different behaviour upon aggressive optimization tend to be related to insufficient use of the volatile qualifier.
unfortunately also i have always used SPL, but this project requires HAL: a good opportunity to know better these drivers but also an effort to adapt to a very different point of view.
It's a pity that this simple thing isn't working out of the box with any optimisation, after all i've written the code in a very naive way: only hal irq handlers are used inside the isr services, as also done by mx cube.
Davide
ps: any further info is well accepted, also if there is a way to point out this issue to the hal drivers team i'll be happy to contribute!