2016-03-14 07:24 AM
Hello,
there is a bug in the HAL library file stm32f3xx_hal_dac_ex.c when using STM32F334.The file version is 1.2 (last version in the firmware package 1.4 for STM32F3).I want to enable the output switch for the DAC2 output 1.The bug is in the function HAL_DAC_ConfigChannel().The DAC2 output 1 doesn't have a buffer output but a switch output.Lines concerned /* Configure for the selected DAC channel: buffer output or switch output, trigger *//* Set TSELx and TENx bits according to DAC_Trigger value */
/* Set BOFFx bit according to DAC_OutputBuffer value OR */
/* Set OUTEN bit according to DAC_OutputSwitch value */
#if defined(STM32F328xx)
tmpreg2 = (sConfig->DAC_Trigger | sConfig->DAC_OutputSwitch);
#elif defined(STM32F334x8)
if (Channel == DAC_CHANNEL_1) /* DAC1 channel 1 or DAC2 channel 1*/
{
tmpreg2 = (sConfig->DAC_Trigger | sConfig->DAC_OutputBuffer);
}
else /* DAC1 channel 2 */
{
tmpreg2 = (sConfig->DAC_Trigger | sConfig->DAC_OutputSwitch);
}
#elif defined(STM32F303x8)
/* DAC1 channel 1 */
if ((hdac->Instance == DAC1) && (Channel == DAC_CHANNEL_1))
{
tmpreg2 = (sConfig->DAC_Trigger | sConfig->DAC_OutputBuffer);
}
else /* DAC1 channel 2 & DAC2 channel 1 */
{
tmpreg2 = (sConfig->DAC_Trigger | sConfig->DAC_OutputSwitch);
}
#else
tmpreg2 = (sConfig->DAC_Trigger | sConfig->DAC_OutputBuffer);
#endifThis should be /* Configure for the selected DAC channel: buffer output or switch output, trigger */
/* Set TSELx and TENx bits according to DAC_Trigger value */
/* Set BOFFx bit according to DAC_OutputBuffer value OR */
/* Set OUTEN bit according to DAC_OutputSwitch value */
#if defined(STM32F328xx)
tmpreg2 = (sConfig->DAC_Trigger | sConfig->DAC_OutputSwitch);
#elif defined(STM32F303x8)
if (Channel == DAC_CHANNEL_1) /* DAC1 channel 1 or DAC2 channel 1*/
{
tmpreg2 = (sConfig->DAC_Trigger | sConfig->DAC_OutputBuffer);
}
else /* DAC1 channel 2 */
{
tmpreg2 = (sConfig->DAC_Trigger | sConfig->DAC_OutputSwitch);
}
#elif defined(STM32F334x8)
/* DAC1 channel 1 */
if ((hdac->Instance == DAC1) && (Channel == DAC_CHANNEL_1))
{
tmpreg2 = (sConfig->DAC_Trigger | sConfig->DAC_OutputBuffer);
}
else /* DAC1 channel 2 & DAC2 channel 1 */
{
tmpreg2 = (sConfig->DAC_Trigger | sConfig->DAC_OutputSwitch);
}
#else
tmpreg2 = (sConfig->DAC_Trigger | sConfig->DAC_OutputBuffer);
#endif
Philippe
2016-03-15 08:16 AM
Hi Philippe,
Thanks for highlighting this bug. It is reported internally. However, I don't agree totally with the solution that you suggested. In fact, it will be OK for STM32F334, but not other lines. Referring to all STM32F3 reference manuals and mainly RM0364 and RM0316, we conclude the following:for all STM32F3 lines except (STM32F334xx, STM32F303x6/8, STM32F328): the available DAC channel has a DAC output buffer. However, for (STM32F334xx, STM32F303x6/8, STM32F328): - DAC1_CH1 has an output buffer - DAC1_CH2 has an output switch - DAC2_CH1 has an output switch So, the implementation should be like this:#if defined(STM32F303x8) || defined(STM32F334x8) || defined(STM32F328x8)
/* DAC1 channel 1 */
if
((hdac->Instance == DAC1) && (Channel == DAC_CHANNEL_1))
{
tmpreg2 = (sConfig->DAC_Trigger | sConfig->DAC_OutputBuffer);
}
else
/* DAC1 channel 2 & DAC2 channel 1 */
{
tmpreg2 = (sConfig->DAC_Trigger | sConfig->DAC_OutputSwitch);
}
#else
tmpreg2 = (sConfig->DAC_Trigger | sConfig->DAC_OutputBuffer);
#endif
-Mayla-
To give better visibility on the answered topics, please click on Accept as Solution on the reply which solved your issue or answered your question.
2016-03-16 06:36 AM
Hi Mayla,
you are right because i just looked for the STM32F334 and not for other references.ThanksPhilippe