STM32L451VETR: DAC output drops to 0 after BOR event in STOP2 mode
I am facing a strange issue that looks like a possible microcontroller design/behavior problem.
My setup:
I need the DAC output pin to provide a stable voltage while the microcontroller is in STOP2 sleep mode with the RTC running.
Power connections: Vbat, Vdda, and Vref are connected to Vdd.
An additional external supervisor is used: MCP130T-270I/TT.
Problem description:
Initially, everything works fine — the DAC output stays at the expected voltage in STOP2 mode.
However, after a BOR (Brown-Out Reset) occurs, the behavior changes: when the microcontroller enters STOP2 mode, the DAC output pin drops to 0V.
After this happens:
Resetting the microcontroller does not fix it.
Power-cycling the device also does not fix it.
The only way to recover normal DAC behavior is to connect via debugger.
Has anyone experienced similar behavior? Could this be a silicon bug, or am I missing some configuration after BOR?
My DAC config:
sConfig.DAC_SampleAndHold = DAC_SAMPLEANDHOLD_ENABLE;
sConfig.DAC_SampleAndHoldConfig.DAC_HoldTime = 10;
sConfig.DAC_SampleAndHoldConfig.DAC_RefreshTime = 10;
sConfig.DAC_SampleAndHoldConfig.DAC_SampleTime = 10;
sConfig.DAC_Trigger = DAC_TRIGGER_NONE;
sConfig.DAC_OutputBuffer = DAC_OUTPUTBUFFER_ENABLE;
sConfig.DAC_ConnectOnChipPeripheral = DAC_CHIPCONNECT_DISABLE;
sConfig.DAC_UserTrimming = DAC_TRIMMING_FACTORY;
if (HAL_DAC_ConfigChannel(&hdac1, &sConfig, DAC_CHANNEL_1) != HAL_OK)
{
Error_Handler();
}
void sleep(void)
{
HAL_RTCEx_SetWakeUpTimer_IT(&hrtc, 0xA000, RTC_WAKEUPCLOCK_RTCCLK_DIV16);
HAL_PWREx_EnterSTOP2Mode(PWR_STOPENTRY_WFI);
}
Test case:
HAL_DAC_Start(&hdac1, DAC_CHANNEL_1);
HAL_DAC_SetValue(&hdac1, DAC_CHANNEL_1, DAC_ALIGN_12B_R, 1000);
sleep();
HAL_DAC_SetValue(&hdac1, DAC_CHANNEL_1, DAC_ALIGN_12B_R, 2000);
sleep();
