2023-09-28 04:30 PM
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:
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.
I am using a semaphore in each task (ADC_StoreData and MQTTClientPubTask).
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).
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
2023-09-29 06:27 AM
> 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.