2024-01-16 05:16 AM
__IO volatile uint8_t ADC_ConversionFlg=0;
void HAL_ADC_ConvCpltCallback(ADC_HandleTypeDef *hadc)
{
/* Prevent unused argument(s) compilation warning */
/*
ADC_ConversionFlg |= 0x01;
CTP=HAL_ADC_GetValue(&hadc1);
}
MX_ADC1_Init();
HAL_ADC_Start_IT(&hadc1);
while (1)
{
if (ADC_ConversionFlg & 0x1){
//CTP=HAL_ADC_GetValue(&hadc1);
ADC_ConversionFlg &= ~(0x01);
}
}
So i am using the Interupt method to get the converted value but after the conversion when the
callback is triggered and the value is stored ,it is not exiting from the callback function,
it should go to the while loop and continue , but it is stuck in the callback function only ,
what could be the reason , can someone help?
2024-01-16 05:47 AM
Probably your rate of converting is so fast the cpu is swamped with interrupts.
Lower your sample rate to fix. Interrupts frequency should be limited to around 10 kHz max in general.
2024-01-16 11:39 PM
Thank you , I think this was the issue.
Now i am trying to increase the time of ADC sampling by doing two thing-
1. I am increasing the ADC_SAMPLETIME To ADC_SAMPLETIME_640CYCLES_5. This is the max available.
2. I am setting the clock prescaler to ADC_CLOCK_SYNC_PCLK_DIV4 to decrease the ADC clock frequency and increase the sampling time .
But it is still to fast , I am only able to get out the interrupt few times only, So is there some other ways to increase the sampling time.
And I am using Continuous conversion mode , is this can be the reason?
I am trying to use 4 ADC channel and triggering the same interrupt like this -
void HAL_ADC_ConvCpltCallback(ADC_HandleTypeDef *hadc)
{
/* Prevent unused argument(s) compilation warning */
if(hadc == &hadc1)
{
ADC_ConversionFlg |= 0x01;
}
else if(hadc == &hadc2)
{
ADC_ConversionFlg |= 0x02;
}
else if(hadc == &hadc3)
{
ADC_ConversionFlg |= 0x04;
}
else if(hadc == &hadc4)
{
ADC_ConversionFlg |= 0x08;
}
// if (HAL_ADC_Stop_IT(hadc)!=HAL_OK){
// Error_Handler();
// }
// ADC_ConversionFlg |= 0x01;
// CTP=HAL_ADC_GetValue(&hadc1);
}
Previously for this i used to stop the ADC then restarted again for the second time .
Can you suggest some way, it would be very helpful ,
Thank you in advance.
2024-02-05 07:56 AM
Hello Tushar_4
Thank you for contacting STMicroelectronics. Your inquiry is being escalated for specialized support.
Kind Regards,
Christian
ST Support