Question
[Need Help] Hard Fault Analysis On LR after ADC check HAL_OK
Hi i am a student, building a program using STM32F4 Discoery board for my research's hardware. So my program which i write for STM32F4 Discovery board has been stuck in Hard Fault after certain ADC Poll code. An overview of my code is :
-
Use different ADC Channels from ADC1 only (just 1 ADC, multi channel) to read 3 sensors.
-
Each time i about to read any ADC channel i configure the channels (e.g 2 or 5) >> start hadc1 >> poll conversion >> get the value >> stop hadc1 and i repeat that for other channels.
-
After some calculation programs i fetch it to USART
After reading a blog about HardFault analyzer, i managed to tweak my code and get the info about on which line i got stuck, including the LR and PC (showed by number 1 in the pic, top left). Turns out it is faulting when it is checking whether HAL_OK is TRUE in the main.c (number 3 in the pic, bottom).
The LR (call return address) has the adress 0x08000955 whis is not listed in the dissasembly (number 2 in the pic, top right)
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.
But i am not really sure about it. Also, if thats the case then i would need group member's suggestion on how to deal with the fault. So i dont really know how what to do in this situation. Could anyone please help me?
some notes:
The USART works fine, i did try the code by commenting out the ADC related code (using //) and using incremental values as dummy data.
I get the code for hardfault analyzer from https://blog.frankvh.com/2011/12/07/cortex-m3-m4-hard-fault-handler/?fbclid=IwAR38jqwSyveyoR2kRRc5nhSZh1hzRjciieVDZ57452Ess0HuCUGAgeMUp6I
I had some trouble with HAL getting locked which send me to the Hal_Locked instance
But, I changed the Hal_Locked function so it can unlock itself in stm32f4xx_hal_def.h.
heres the Hal_locked function
_____________________________________________________________
