cancel
Showing results for 
Search instead for 
Did you mean: 

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

msche.1
Associate III

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?

5 REPLIES 5
DShri.1
Associate II

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

BillR
Associate III

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

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

Najib Kassab
Associate III

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

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