ADC converstion doesn't complete, if (RCM_GetUserConvState() == RCM_USERCONV_EOC) is never true.
Dear members,
I am using the NUCLEO-F303RE and X-NUCLEO-IHM08M1 boards. I have created a position control project which seems to work fine. At this stage I would like to introduce an ADC conversion, however I am able to request an ADC conversion but this never completes.
Below is the code I have. Did anyone have a similar issue?
RegConv_t PotentiometerConv;
uint8_t PotentiometerHandle;
void PotentiometerInitialise (void)
{
PotentiometerConv.regADC = ADC1;
PotentiometerConv.channel = ADC_CHANNEL_9;
PotentiometerConv.samplingTime = ADC_SAMPLETIME_61CYCLES_5;
PotentiometerHandle = RCM_RegisterRegConv(&PotentiometerConv);
}
if(RCM_GetUserConvState() == RCM_USERCONV_IDLE) /*if Idle, then program a new conversion request*/
RCM_RequestUserConv(PotentiometerHandle);
if (RCM_GetUserConvState() == RCM_USERCONV_EOC) //if conversion is ready to be read
{
pot = RCM_GetUserConv(); //this returns the ADC value (the returned value is between [0 and 65535] where the max value equivals to 3,3V)
if ((pot>=low_ref) && (pot<=high_ref)) //this means 1.65V +- tollerance
MC_ProgramPositionCommandMotor1(0,0);
//stop_motor();
else if (pot>high_ref) //values above 1.67V
rotate_clockwise();
else if (pot<low_ref) //values below 1.646V
rotate_anticlock();
else
MC_StopMotor1();
}