How to configure and read the accumulated value on ADC using the ADC_CHANNEL_ACCUMULATE mode.
The difference between ADC_CHANNEL_NORMAL and ADC_CHANNEL_ACCUMULATE is following:
ADC_CHANNEL_NORMAL gives one value per ADC IP conversion complete flag (i.e. if ADC peripheral returns a value, this value is passed to the application) and the application gets lwevent flag after sequence of conversions is recorded.
ADC_CHANNEL_ACCUMULATE gives one value per sequence, there you can find accumulated value (sum) of all the ADC peripheral values during a sequence.
Open a channel with ADC_CHANNEL_ACCUMULATE and wait for and lwevent defined in the init structure. Then, read the value with read() function from ADC driver. The value will contain accumulated values from last sequence ADC results.
Does in ADC_CHANNEL_NORMAL when I read one value the ADC IP returns a arithmetic mean or only the first didn´t read value?
Does in ADC_CHANNEL_NORMAL I need a buffer with size equal the number of samples?
I'm asking because I read the code from ADC driver and when its use the ADC_CHANNEL_ACCUMULATE mode, you don´t need to allocate buffer to the samples, reducing the memory requirements, but in this mode the read function never returns a value different from zero, blocking forever the application.
ADC IP returns Analog to Digital Conversion value, depending on how ADC peripheral is set- some ADC IP integrate HW arithmetic averaging.
The second question is mistyped, can you repeat?
ADC_CHANNEL_ACCUMULATE - you need to allocate some space for sure, but compared to ADC_CHANNEL_NORMAL with the same settings, ADC_CHANNEL_ACCUMULATE result is returned with N times lower frequency, where N is the number of samples in one sequence (ADC_CHANNEL_ACCUMULATE returns ONE accumulated value of N samples, unlike ADC_CHANNEL_NORMAL returns N separate values).
Use lwevent to check if your application should read accumulated value.