cancel
Showing results for 
Search instead for 
Did you mean: 

ADC and Asynchronous clock mode?

Arman Ilmak
Senior

Hi guys. I designed a simple PCB for measuring the battery voltage of a biomedical instrument. But I faced a simple problem. I use HAL to generate the code. So when I set the ADC clock in Asynchronous clock mode the while(1) is not executed!!!

IS it because of ADC interrupt happen too fast so the while cannot be executed?

5 REPLIES 5
T J
Lead

Can you single step ?

where does it get stuck ?

code example ?

The help you get depends on the details you provide...

Arman Ilmak
Senior

I can't even toggle a pin.

It gets stuck in the ADC callback function(The ADC is working properly, I mean that the MCU does not hang).

Arman Ilmak
Senior

I don't know why I am not able to attach files.As soon as I can I will upload it.

Arman Ilmak
Senior

Finally I could upload it.

T J
Lead

void HAL_ADC_ConvCpltCallback(ADC_HandleTypeDef* hadc)

 {

     data=3.3*ADC_DIVIDER*HAL_ADC_GetValue(hadc)/4095;

}

should be 4096 ;

I dont use the interrupt call back,I use the DMA function, then when every I look at the data it is fresh...

   HAL_ADC_Start_DMA(&hadc, (uint32_t *)ADC_DMABuffer, ADC_ChannelCount);