I am trying to store DMA buffer array such as below;

////////////////////Global Area;////////////////////////////////////////

uint16_t ADC_Vbatt=0;
uint16_t ADC_buffer[2];

/////////////////main function/////////////////////////////////////////


HAL_ADC_Start_DMA(&hadc, (uint32_t*)ADC_buffer,2);

ADC_Vbatt = ADC_buffer[1];


but when I look in debug mode, ADC_Vbatt variable is empty. I do not understand why.

So, how to store ADC_buffer[2] array in two variable?

  • \$\begingroup\$ Is this an STM32? \$\endgroup\$ – DiBosco Jun 19 '18 at 11:39
  • 3
    \$\begingroup\$ If the function name suggest meaninfully, you just start the DMA transfer. You never wait for it to finish before reading the target. \$\endgroup\$ – Marcus Müller Jun 19 '18 at 11:48
  • \$\begingroup\$ -DiBosco -> Yes, this is STM32L011K4 -Marcus -> I do not fully understand. Could you please explain detailed? \$\endgroup\$ – Purgoufr Jun 19 '18 at 12:40
  • 4
    \$\begingroup\$ you just started the DMA copy process. You don't wait for the copy to finish. \$\endgroup\$ – Marcus Müller Jun 19 '18 at 13:51
  • \$\begingroup\$ So normally values are being recorded, but I can not notice it in debug mode. Is it true? \$\endgroup\$ – Purgoufr Jun 20 '18 at 20:14

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.