cancel
Showing results for 
Search instead for 
Did you mean: 

Hard fault interrupt while using ADC with DMA and MQTT

ALoua.1
Associate II

Hello, 

I am working on a project where I get sensor values from ADC and then send those values via MQTT. I am using FreeRTOS. 

For the ADC configuration: 

  • DMA activated 
  • Scan mode ENABLED
  • Continous mode ENABLED
  • DMA continuous requests ENABLED

For the MQTT configuration, I used a GitHub project  (ETH interrupt is enabled). 

For each sample, I want to store the new data coming from NBR_OF_CHANNELS channels in the tmp[NBR_OF_CHANNELS][NBR_OF_SAMPLES] buffer. 200600cdca96f0391d803ab40670cd8f2de8dc5e.png

I am using a semaphore in each task (ADC_StoreData and MQTTClientPubTask). 

6c091a153c782994d5093ac1b32f687a2b1955e4.png

The adcValues is filled in each sample (meaning it is working fine) but the tmp buffer is only filled with the first value of the adcValues (first value of the first channel in the the first sample). 

17632e5211547b63e07f071bbd8c56784b2a61de.png

I tried to add work with DMA interruption and using the CompleteConversionCallBack() after the end of each sequence, but I got a problem with the ETH interrupt. 

 

The task is easy:

- Collect data from 4 channels 

- Store this data in a buffer for each sample 

- Send the Data via MQTT. 

I appreciate any help! 

Thank you,

Ahmed

 

1 REPLY 1
TDK
Guru

 

> tmp buffer is only filled with the first value of the adcValues

HAL_ADC_Start_DMA isn't instantaneous. The DMA will work in the background to store values until it's complete. Wait until the operation is complete before reading or acting on those values.

If you feel a post has answered your question, please click "Accept as Solution".