Skip to main content
msche.1
Associate III
Feb 28, 2022 10:43 PM UTC
Question

Why does STM32MP1 DMA ADC work in Engineering mode, but not in when I compile it and use `fw_cortex_m4.sh`?

First I declare the buffer length

/* USER CODE BEGIN PD */
#define ADC_BUF_LEN 10000

Then I declare the buffer

/* USER CODE BEGIN PV */
GPIO_InitTypeDef gpio_init_structure;
VIRT_UART_HandleTypeDef huart0;
VIRT_UART_HandleTypeDef huart1;
uint16_t adc_buf[ADC_BUF_LEN];

I've enabled the VREF

/* USER CODE BEGIN 2 */
// Enable the VREF clock
__HAL_RCC_VREF_CLK_ENABLE();
// Disable the high impedance mode which is the default one read page 1694 of refman
	HAL_SYSCFG_VREFBUF_HighImpedanceConfig(SYSCFG_VREFBUF_HIGH_IMPEDANCE_DISABLE);
HAL_SYSCFG_VREFBUF_VoltageScalingConfig(SYSCFG_VREFBUF_VOLTAGE_SCALE2);
// To enable VREFBUF
HAL_SYSCFG_EnableVREFBUF();

Finally I start the ADC over DMA

HAL_ADC_Start_DMA(&hadc1, (uint32_t*)adc_buf, ADC_BUF_LEN);

I seem to get reasonable values when in engineering mode and look at variables in debug mode, however, when I build for release, then scp the file to the Linux core, then use the fw_cortex_m4.sh to forward the elf file, I get values of 4095.0000 every time.

I've also noticed that even though I'm using ANA1 which according to this documentation is linked to the PIN A3, but it actually seems to only work on A2, is this an error in the documentation?

This topic has been closed for replies.

5 replies

DShri.1
Associate
Mar 25, 2022 3:06 PM UTC

Hi @msche.1​  . I am experiencing the same issue. Did you manage to get it to work eventually?

BillR
Associate III
Mar 25, 2022 3:16 PM UTC

Hi, just a quick thought but could Linux be turning off the reference thinking its unused? It sounds reminiscent of:

https://community.st.com/s/question/0D53W00000asEyaSAE/dac-stops-working-on-m4-side-shortly-after-linux-boots

DShri.1
Associate
Mar 25, 2022 4:07 PM UTC

Hi @BillR​ thanks for the suggestion. I will check it out

Najib Kassab
Associate III
Jan 5, 2023 12:40 PM UTC

I have the same issue here, and I think it's because OPENAMP is enable in production mode or when Linux is running, However, I still don't know why or how to fix it.

Steffen M
Associate II
Jul 28, 2023 3:28 PM UTC

Is there any chance to share the project which is working in engineering mode?
I read 0x8000 regardless if I am in production or engineering mode in the ADC_DR register.
Thank you