2019-02-12 06:21 AM
I'm trying to read adc value from 5 channels. I used CubeMX to generate the code (i do have stm32l462vetx) ... each time i run the code, runs for maybe 10s and find myself in the "HardFault_Handler" .. I have tried dropping simpling cycles, clock, ... but nothing helps .. does anyone have an idea ?
thnx
2019-02-12 07:14 AM
A Hard Fault typically means you're screwing up something with the memory buffers, or have an inadequate stack allocation, corrupted it, or missing some IRQ Handler.
When using DMA the activity will outlive local/auto variables, and can corrupt memory in the background.
Get a proper Hard Fault Handler that can report registers, locations and diagnostics, and get to the root cause of that. Looking at the ADC initialization code probably isn't going to get you there.
2019-02-12 07:23 AM
> ... runs for maybe 10s and find myself in the "HardFault_Handler" ...
Sounds like a stack overflow on first glance (coincidental occurence of multiple interrupts, or interrupt/code superposition).
Fault causes and register contents will fluctuate in this case.
2019-02-12 08:04 AM
Yes, the default Stack/Heap values in CubeMX are far from filling the MCU RAM in most cases....