cancel
Showing results for 
Search instead for 
Did you mean: 

Reading multiple adc channel

ARake
Associate

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

3 REPLIES 3

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.

Tips, Buy me a coffee, or three.. PayPal Venmo
Up vote any posts that you find helpful, it shows what's working..
AvaTar
Lead

> ... 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.

S.Ma
Principal

Yes, the default Stack/Heap values in CubeMX are far from filling the MCU RAM in most cases....