cancel
Showing results for 
Search instead for 
Did you mean: 

Can't get aDC's to go to 0

erastusC
Associate II

I have4 set up a 9 channel DMA adc

Below is the DMA configuration in the IDE

erastusC_0-1747069676122.png

This is the ADC configuration

erastusC_1-1747070270391.png

This is the IRQ routine

erastusC_2-1747071506918.png

This is where I treat the data.  For every loop it gets added to another array after the conversion.

Then a simple routine that divides the accumulated value by the amount of conversion and then some tweaking

erastusC_3-1747071729503.png

On A1 I have a potentiometer with a dividing resistor that I take 28V down to 3.3V the CPU voltage. Very basic

It seems that the conversion get scattered on all the channels and the max reading I can get is 170 with 1.3V on A0.

This is the aray  volatile: 

uint16_t AD_RES_BUFFER[11] = {0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0};

 

I am not sure what is happening can any one please assist.

Thanks

1 ACCEPTED SOLUTION

Accepted Solutions
erastusC
Associate II

Many thanks.

I did find the fault.

 

HAL_ADC_Start_DMA(&hadc1, (uint32_t*) AD_RES_BUFFER, 9);  

The 9 was set to 11.  11 For ref and internal temp.

I expected the "driver" to start from channel 01 (1) which it did not do.

 

My fault.

Thanks

View solution in original post

2 REPLIES 2
bramble
Senior

Hi @erastusC , 

I would suggest simplifying your setup to reproduce the issue with fewer variables and fewer possible places where a mistake might be made. 

A single channel ADC with input connected to 0 or 3.3v should result in the full ADC range, and once that's working you could start adding complexity such as: enable cache (if wanted), add DMA, multiple channels and your post-processing code etc. 

 

Good luck, hope this helps.

erastusC
Associate II

Many thanks.

I did find the fault.

 

HAL_ADC_Start_DMA(&hadc1, (uint32_t*) AD_RES_BUFFER, 9);  

The 9 was set to 11.  11 For ref and internal temp.

I expected the "driver" to start from channel 01 (1) which it did not do.

 

My fault.

Thanks