ADC readings
Hello,
I have a problem witht he ADC readings and the timing of reading of the ADC channels.
I am currently using an STM32 U545, both ADCs (1 & 4) configured to read voltage values comming from different sensors that i have on my pcb. The ADC is configured in DMA mode so i can have this reading process runing in parallel and the ADCs are triggered with a timer so that i have full control of the ADC switching. Setting the ADC in continuous/discontinuous conversion mode is not an option for me.
The problem comes when i try to make a function where all the voltage values and temperature values are monitored to check if they are in range so that if they are not the system does not start/stops and informs me which error do i have.
The parameters i try to monitor are the following ones:
void ADC_Calibration(void){
I_BAT = (float)ADC1_VALUES[0] * K_I_BAT + D_I_BAT; // CURRENT VOLTAGE
U_BAT = (float)ADC1_VALUES[1] * K_U_BAT + D_U_BAT; // U_BAT BATTERY VOLTAGE
U_A = (float)ADC1_VALUES[2] * K_U_A + D_U_A; // OUT A VOLTAGE VALUE
U_B = (float)ADC1_VALUES[3] * K_U_B + D_U_B; // OUT B VOLTAGE VALUE
TBAT_1 = (float)ADC4_VALUES[0] * K_TBAT_1 + D_TBAT_1; // TEMPERATURE BAT1
TBAT_2 = (float)ADC4_VALUES[1] * K_TBAT_2 + D_TBAT_2; // TEMPERATURE BAT2
TBAT_3 = (float)ADC4_VALUES[2] * K_TBAT_3 + D_TBAT_3; // TEMPERATURE BAT3
}
The function that monitors the parameters is the following one:
void error(void) {
//if ((TBAT_1 < TEMPERATURE_LIMIT && TBAT_2 < TEMPERATURE_LIMIT && TBAT_3 < TEMPERATURE_LIMIT) &&
//(U_BAT > V_LOWER_LIMIT && U_BAT < V_UPPER_LIMIT) &&
//(I_BAT > I_LIMIT_NEGATIVE && I_BAT < I_LIMIT_POSITIVE)) {
//error_flag = 0;
//return;
//}
// Overcurrent (positive)
if (I_BAT > I_LIMIT_POSITIVE) {
error_flag = 1;
}
// Overcurrent (negative)
else if (I_BAT < I_LIMIT_NEGATIVE) {
error_flag = 2;
}
// Overvoltage
else if (U_BAT > V_UPPER_LIMIT) {
error_flag = 3;
}
// Undervoltage
else if (U_BAT < V_LOWER_LIMIT) {
error_flag = 4;
}
// Overtemperature
else if (TBAT_1 > TEMPERATURE_LIMIT || TBAT_2 > TEMPERATURE_LIMIT || TBAT_3 > TEMPERATURE_LIMIT) {
error_flag = 5;
}
if (error_flag != 0) {
enable_pwm = 0;
setPWM(0);
}
}
The problem im encountering is the following one:
Everytime the ADC starts, the buffer where all the data comming from the sensors goes is filled with 0. So everytime i try to intiate the program it obiously detects that the values are out of range and therefore i cant initiate the program and the error flag instantly pops up.

Is there anyway i can "wait" for the ADC without introducing any kind of blocking mode in the program?
