2024-01-02 08:00 PM - last edited on 2024-01-05 04:18 AM by SofLit
I think the bad LR address might be the problem, i.e. reffering to the non-exist address in disassembly, note that in disassembly window (number 2) there is no address 0x8000955 after 0x08000954, but it goes straight to 0x8000956 instead.
2024-01-03 12:54 AM
Hello @dios_kuri,
Could you please share your project?
Thank you!
To give better visibility on the answered topics, please click on Accept as Solution on the reply which solved your issue or answered your question.
2024-01-03 02:14 AM - edited 2024-01-03 02:22 AM
>The LR (call return address) has the adress 0x08000955 whis is not listed in the dissasembly
The address is actually 0x08000954. (Clear the lowest bit. this is because of thumb instruction set TL;DR)
2024-01-03 06:46 AM
Thanks for the insight, Pavel. But I am sorry i don't understand how to clear the lowest bit, and i dont know where to put it since the code is an if code to check if hal_adc_configchannel is OK. May i get an example?
Any kind of suggestion helps.
2024-01-03 06:53 AM
2024-01-03 07:01 AM
Inconveniently you truncate the register display in the screen shot.
Problem is likely with one of the parameters / structures passed to HAL_ADC_ConfigChannel()
2024-01-03 07:04 AM
More registers, denser display
https://github.com/cturvey/RandomNinjaChef/blob/main/KeilHardFault.c
2024-01-03 07:21 AM
Hi Tesla.
Below the complete view of the registers, printf debug, and disassembly window. Hope this can give more insight. The code is slightly different then the one i posted, but the problem is still the same (i.e. LR address doesnt exist and on the same line of code which is for checking if hal config adc is OK.
Many thanks in advance.
-Dios
==================================================
Line of code
==================================================
Registers:
==================================================
full printf debug window:
==================================================
Disassembly window:
==================================================
2024-01-03 08:35 AM
> LR address doesnt exist
As @Pavel A. said, [in your head] mask the LR LSB (set it to 0) to get 0x8001ec2 AS THE RETURN ADDRESS.
But LR is not what you should be paying attention to. Look at the PC value 0x8000203a, THAT is where the problem was. As @Tesla DeLorean said, it is probably an issue with the configuration structure you pass (0 in some field that expects a non-zero value, perhaps).
2024-01-03 09:01 AM
You're interested in the code that faults, not the return address for the last function call.
The fault is likely somewhere in HAL_ADC_ConfigChannel() when you use the parameters / pointers passed in. Probably &hadc1
Suggest if you have printf() working, that a) you print out the pointer "%p", b) dump out the structure, and c) the pointer for hadc->Instance