2018-04-11 04:41 PM
STM32L151R8 - I'm using the Injection channels with a 4 channel sequence. The conversion is handled by software and is repeated immediately (on a different set of data). This works fine for a while. Eventually, the second polling loop fails with a timeout. After some debugging, I found it always fails on the second polling loop. Also, when it fails, no amount of waiting will ever make it pass. (TheJEOC bit never goes high).
I am using the regular ADC channels as well, but I don't believe this problem is coupled with the regular channels. I disabled the trigger to the ADC channels, so no conversions are occurringduring this code. This made no difference.
Injection code:
assert(HAL_ADCEx_InjectedStart(&hadc) == HAL_OK);
NOP();
assert(HAL_ADCEx_InjectedPollForConversion(&hadc,5) == HAL_OK);
for(i=0; i<ADC_INJ_NUMCONV; i++) {
data1[i] = HAL_ADCEx_InjectedGetValue(&hadc,ADC_INJECTED_RANK_1+i);
}
// Change external MUX to put new data into injection inputs
assert(HAL_ADCEx_InjectedStart(&hadc) == HAL_OK);
NOP();
assert(HAL_ADCEx_InjectedPollForConversion(&hadc,5) == HAL_OK); //Fails!
for(i=0 ; i<ADC_INJ_NUMCONV; i++) {
data2[i] = HAL_ADCEx_InjectedGetValue(&hadc,ADC_INJECTED_RANK_1+i);
}�?�?�?�?�?�?�?�?�?�?�?�?�?�?�?�?�?�?�?�?�?�?�?�?�?�?
Note, as a workaround, I tried replacing the polling all with the following:
void inject_wait(void) {
while(HAL_ADCEx_InjectedPollForConversion(&hadc,2) != HAL_OK) {
assert(HAL_ADCEx_InjectedStart(&hadc) == HAL_OK);
}
}�?�?�?�?�?�?�?�?�?�?
This basicallykeeps trying to start the injection conversion, until it succeeds. This never causes an assertion, but the data conversion is not done correctly. What I see is data from the previousconversion. It's like the injection converter needs a break between executions (?).
2018-04-11 05:44 PM
FYI - You can see the impact of this error. The spikes in the data are caused by failed conversions on the injection channels. With some work, it was determined, the erroneous reads are simply data from the previous conversion.