2020-02-11 05:42 AM
Dear all,
I am trying to read 3 ADCs channels using scan continuous mode and DMA with a STM32H7 (ADC3). Below the CubeMx settings + DMA.
In the main, before the While(1) loop I start the ADC with:
HAL_ADC_Start_DMA(&hadc3, (uint32_t*)adc_data, 3) ;
Where ADC_Values is uint32_t adc_data[3];
When I run the debugger, adc_data is always 0x0000.
Any hint?
Thanks
2020-02-11 08:21 PM
Are you handling the buffer coherency issue for ADC DMA read buffer correctly?
https://community.st.com/s/article/FAQ-DMA-is-not-working-on-STM32H7-devices
2020-02-12 02:19 AM
Hello @Yoichi Shinoda , thank you for your answer. I came accross that article and I think that's the issue I have. I tried to follow it but I think my knowledge about STM32 MCUs is too limited to really understand it ..
2020-02-27 02:33 AM
Hello,
You should change the memory address, as shown in Figure (when using IAR)
Please find attached the RM0433 Rev 6 (page 101, 128) link for more clarification
Regards
2020-03-10 05:58 AM
Hi all,
User have to do this update
define symbol __ICFEDIT_region_RAM_start__ = 0x24000000;
define symbol __ICFEDIT_region_RAM_end__ = 0x2407FFFF;
manually (in the stm32h743xx_flash.icf ) since linker file is not managed by STM32CubeMX (copied from the FW package).
Best regards,
Nesrine
2020-04-03 12:20 AM
Dear @Nesrine.JLASSI , is this equivalent to setting the IRAM2 region in the target option in Keil ?
2020-04-03 07:05 AM
Hello @Nesrine.JLASSI and @Imen GH , modifying the IRAM2 in Keil did the trick. Now I can see the data being acquired by the MCU. However, I noticed that despite the ADC resolution is set to 16bits, I can only read 8bits since the the 8 LSBs are always 0, as shown in the debugger view below:
where :
uint16_t adc_data[7];
HAL_ADC_Start_DMA(&hadc1, (uint32_t*)adc_data, 7) ;
ADC initialization code:
static void MX_ADC1_Init(void)
{
/* USER CODE BEGIN ADC1_Init 0 */
/* USER CODE END ADC1_Init 0 */
ADC_MultiModeTypeDef multimode = {0};
ADC_ChannelConfTypeDef sConfig = {0};
/* USER CODE BEGIN ADC1_Init 1 */
/* USER CODE END ADC1_Init 1 */
/** Common config
*/
hadc1.Instance = ADC1;
hadc1.Init.ClockPrescaler = ADC_CLOCK_ASYNC_DIV1;
hadc1.Init.Resolution = ADC_RESOLUTION_16B;
hadc1.Init.ScanConvMode = ADC_SCAN_ENABLE;
hadc1.Init.EOCSelection = ADC_EOC_SEQ_CONV;
hadc1.Init.LowPowerAutoWait = DISABLE;
hadc1.Init.ContinuousConvMode = ENABLE;
hadc1.Init.NbrOfConversion = 7;
hadc1.Init.DiscontinuousConvMode = DISABLE;
hadc1.Init.ExternalTrigConv = ADC_SOFTWARE_START;
hadc1.Init.ExternalTrigConvEdge = ADC_EXTERNALTRIGCONVEDGE_NONE;
hadc1.Init.ConversionDataManagement = ADC_CONVERSIONDATA_DMA_CIRCULAR;
hadc1.Init.Overrun = ADC_OVR_DATA_PRESERVED;
hadc1.Init.LeftBitShift = ADC_LEFTBITSHIFT_NONE;
hadc1.Init.OversamplingMode = ENABLE;
hadc1.Init.Oversampling.Ratio = 8;
hadc1.Init.Oversampling.RightBitShift = ADC_RIGHTBITSHIFT_3;
hadc1.Init.Oversampling.TriggeredMode = ADC_TRIGGEREDMODE_SINGLE_TRIGGER;
hadc1.Init.Oversampling.OversamplingStopReset = ADC_REGOVERSAMPLING_CONTINUED_MODE;
if (HAL_ADC_Init(&hadc1) != HAL_OK)
{
Error_Handler();
}
/** Configure the ADC multi-mode
*/
multimode.Mode = ADC_MODE_INDEPENDENT;
if (HAL_ADCEx_MultiModeConfigChannel(&hadc1, &multimode) != HAL_OK)
{
Error_Handler();
}
/** Configure Regular Channel
*/
sConfig.Channel = ADC_CHANNEL_3;
sConfig.Rank = ADC_REGULAR_RANK_1;
sConfig.SamplingTime = ADC_SAMPLETIME_387CYCLES_5;
sConfig.SingleDiff = ADC_SINGLE_ENDED;
sConfig.OffsetNumber = ADC_OFFSET_NONE;
sConfig.Offset = 0;
if (HAL_ADC_ConfigChannel(&hadc1, &sConfig) != HAL_OK)
{
Error_Handler();
}
/** Configure Regular Channel
*/
sConfig.Channel = ADC_CHANNEL_4;
sConfig.Rank = ADC_REGULAR_RANK_2;
if (HAL_ADC_ConfigChannel(&hadc1, &sConfig) != HAL_OK)
{
Error_Handler();
}
/** Configure Regular Channel
*/
sConfig.Channel = ADC_CHANNEL_5;
sConfig.Rank = ADC_REGULAR_RANK_3;
if (HAL_ADC_ConfigChannel(&hadc1, &sConfig) != HAL_OK)
{
Error_Handler();
}
/** Configure Regular Channel
*/
sConfig.Channel = ADC_CHANNEL_9;
sConfig.Rank = ADC_REGULAR_RANK_4;
if (HAL_ADC_ConfigChannel(&hadc1, &sConfig) != HAL_OK)
{
Error_Handler();
}
/** Configure Regular Channel
*/
sConfig.Channel = ADC_CHANNEL_14;
sConfig.Rank = ADC_REGULAR_RANK_5;
if (HAL_ADC_ConfigChannel(&hadc1, &sConfig) != HAL_OK)
{
Error_Handler();
}
/** Configure Regular Channel
*/
sConfig.Channel = ADC_CHANNEL_15;
sConfig.Rank = ADC_REGULAR_RANK_6;
if (HAL_ADC_ConfigChannel(&hadc1, &sConfig) != HAL_OK)
{
Error_Handler();
}
/** Configure Regular Channel
*/
sConfig.Channel = ADC_CHANNEL_19;
sConfig.Rank = ADC_REGULAR_RANK_7;
if (HAL_ADC_ConfigChannel(&hadc1, &sConfig) != HAL_OK)
{
Error_Handler();
}
/* USER CODE BEGIN ADC1_Init 2 */
/* USER CODE END ADC1_Init 2 */
}
2022-02-28 03:21 AM
Hi @Mdi c , have you finally solved this issue? In my case, the DMA can only transfer the first byte correctly and leaves the remaining terms to 0.
Thanks
2022-07-24 04:47 AM
did you forget to change the DMA from byte to word?