Hi!
I am implementing new features in an old project. It uses the LL driver, but I programmed this new feature in the newest HAL driver using STMCUBEIDE, my code worked there...
My code compiles without erros but when I debug the code Keil does not allow me to place breakpoints inside the function.
I appreciate the help!
The compiler removes some of your functions because they are not used (at least what I can see from your code snippets). All C-source lines which generate executable code are marked with a dark grey block on the very left side in the editor window. The functions HAL_UARTEx_RxEventCallback() and SN75176A_Callback() are not used and have only a light-grey block on the very left. You can also check the map file of your application. You will find a section "Removing Unused input sections from the image" in it that will list all these functions. Because of this, the debugger cannot set breakpoints in this area.
So in other words, there seems to be no reference to function HAL_UARTEx_RxEventCallback(). Since the only reference to function SN75176A_Callback() is in HAL_UARTEx_RxEventCallback(), the function SN75176A_Callback() also gets removed.
Yes I am aware of this, but if I comment the HAL_UARTEx_RxEventCallback() function the code does not compile.
So technically it was referenced? I`m not understanding this
These are two different things. The compiler needs all definitions and references to compile the code. If something's missing it will throw an error. The linker then decides if functions or variables are really used or not and removes them if not. So the linker already seems to remove the function that references the function HAL_UARTEx_RxEventCallback().
Do you have any suggestions to solve this problem?
Take a look at the disassembly. Is the function being inlined? Looking at your source, the function seems to be just a memcpy() call, then a call to another function, which could be optimized away to save the extra branches.
Try lowering optimization level whilst debugging.
Thank you sir, you saved my day.
Hi ScottWashington if you think that a reply on this thread is the correct answer please could you mark it as an accepted answer? Select Actions > Accept Answer. Many thanks.