Skip to main content
ARake
Visitor II
February 12, 2019
Question

Reading multiple adc channel

  • February 12, 2019
  • 3 replies
  • 906 views

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

This topic has been closed for replies.

3 replies

Tesla DeLorean
Guru
February 12, 2019

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 (See Profile) Up vote any posts that you find helpful, it shows what's working..
AvaTar
Senior III
February 12, 2019

> ... 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
February 12, 2019

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