2019-01-11 08:23 AM
Hello all,
I thought this is a straight forward thing but for me it turned out not to be...
What I want to do is simply using SDADC1 and SDADC2 and perform a regular conversation at a time in multimode. I configured both in CubeMX and tried to sample but the sata register of the ADCs and as well of the DMA show 0. Somebody can see what is the problem? I also didn't find a hint in the examples and application notes. What do I miss?
Thanks a lot for your help guys!
Here are parts of the code:
/* SDADC1 init function */
static void MX_SDADC1_Init(void)
{
SDADC_ConfParamTypeDef ConfParamStruct;
/**Configure the SDADC low power mode, fast conversion mode,
slow clock mode and SDADC1 reference voltage
*/
hsdadc1.Instance = SDADC1;
hsdadc1.Init.IdleLowPowerMode = SDADC_LOWPOWER_NONE;
hsdadc1.Init.FastConversionMode = SDADC_FAST_CONV_DISABLE;
hsdadc1.Init.SlowClockMode = SDADC_SLOW_CLOCK_DISABLE;
hsdadc1.Init.ReferenceVoltage = SDADC_VREF_EXT;
if (HAL_SDADC_Init(&hsdadc1) != HAL_OK)
{
_Error_Handler(__FILE__, __LINE__);
}
/**Configure The Regular Mode
*/
if (HAL_SDADC_SelectRegularTrigger(&hsdadc1, SDADC_SOFTWARE_TRIGGER) != HAL_OK)
{
_Error_Handler(__FILE__, __LINE__);
}
if (HAL_SDADC_MultiModeConfigChannel(&hsdadc1, SDADC_MULTIMODE_SDADC1_SDADC2) != HAL_OK)
{
_Error_Handler(__FILE__, __LINE__);
}
/**Set parameters for SDADC configuration 2 Register
*/
ConfParamStruct.InputMode = SDADC_INPUT_MODE_DIFF;
ConfParamStruct.Gain = SDADC_GAIN_1;
ConfParamStruct.CommonMode = SDADC_COMMON_MODE_VDDA_2;
ConfParamStruct.Offset = 0;
if (HAL_SDADC_PrepareChannelConfig(&hsdadc1, SDADC_CONF_INDEX_2, &ConfParamStruct) != HAL_OK)
{
_Error_Handler(__FILE__, __LINE__);
}
}
/* SDADC2 init function */
static void MX_SDADC2_Init(void)
{
SDADC_ConfParamTypeDef ConfParamStruct;
/**Configure the SDADC low power mode, fast conversion mode,
slow clock mode and SDADC1 reference voltage
*/
hsdadc2.Instance = SDADC2;
hsdadc2.Init.IdleLowPowerMode = SDADC_LOWPOWER_NONE;
hsdadc2.Init.FastConversionMode = SDADC_FAST_CONV_DISABLE;
hsdadc2.Init.SlowClockMode = SDADC_SLOW_CLOCK_DISABLE;
hsdadc2.Init.ReferenceVoltage = SDADC_VREF_EXT;
if (HAL_SDADC_Init(&hsdadc2) != HAL_OK)
{
_Error_Handler(__FILE__, __LINE__);
}
/**Configure The Regular Mode
*/
if (HAL_SDADC_SelectRegularTrigger(&hsdadc2, SDADC_SYNCHRONOUS_TRIGGER) != HAL_OK)
{
_Error_Handler(__FILE__, __LINE__);
}
/**Set parameters for SDADC configuration 2 Register
*/
ConfParamStruct.InputMode = SDADC_INPUT_MODE_DIFF;
ConfParamStruct.Gain = SDADC_GAIN_1;
ConfParamStruct.CommonMode = SDADC_COMMON_MODE_VDDA_2;
ConfParamStruct.Offset = 0;
if (HAL_SDADC_PrepareChannelConfig(&hsdadc2, SDADC_CONF_INDEX_2, &ConfParamStruct) != HAL_OK)
{
_Error_Handler(__FILE__, __LINE__);
}
}
uint32_t sadc1Data[2] = {0,0xFFFF};
HAL_SDADC_Start(&hsdadc2);
HAL_SDADC_MultiModeStart_DMA(&hsdadc1,(uint32_t *) sadc1Data,1);
Best regards,
2019-01-14 09:57 PM
Hello again!
Has anybody an idea?
I still get only strange values. It seems like the ADCs are clipping on the upper or lower end of the voltage. But I cannot really change this behaviour. I often used the SAR-ADCs in other Stm32 in Multimode and never encountered this problem. However, even if I don't use this SDADCs in Multimode I get the same issue.
Thank you a lot in advance.
Best regards,
2021-02-20 05:39 AM
Hi guys, same problem, any news?