cancel
Showing results for 
Search instead for 
Did you mean: 

HAL_ADC_PollForConversion() strange behavior with DMA

RBerg.1
Associate

I am trying to use the code below to read 8 channels from ADC1. I have ADC1 configured with 8 ranks, and have selected "EOC flag at the end of all conversions". HAL_ADC_PollForConversion() hangs forever.

I noticed that if I pass the second argument to HAL_ADC_PollForConversion as 1 less than the number of ranks, all but one of the values gets filled in but HAL_ADC_PollForConversion does return. My current workaround is to configure an extra rank (i.e. configure for 9 ranks, of which I only read the first 8).

#define NUM_CHANNELS 8

void readPowerChannels() {

  uint16_t rawData[NUM_CHANNELS];

  for (int i = 0; i < NUM_CHANNELS; i++) {

    rawData[i] = 13; // So we can see in in the debugger which values are being written

  }

  HAL_ADC_Start_DMA(&hadc1, (uint32_t*) rawData, NUM_CHANNELS);

  HAL_ADC_PollForConversion(&hadc1, HAL_MAX_DELAY);

}

0 REPLIES 0