2025-09-05 6:18 AM
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();
2025-09-05 6:33 AM
A power cycle doesn't fix it? What else on the board is connected to DAC1?
Why is a BOR occurring at all if an external supervisor is being used?
2025-09-05 6:55 AM
Yes, power cycle doesn't fix it, even I short a capacitors on MCU to discharge everything.
DAC1 output is connected to external amplifier input.
I added:
if (__HAL_RCC_GET_FLAG(RCC_FLAG_BORRST))
{
__HAL_RCC_CLEAR_RESET_FLAGS();
__HAL_RCC_BACKUPRESET_FORCE();
asm("nop");asm("nop");asm("nop");asm("nop");asm("nop");
__HAL_RCC_BACKUPRESET_RELEASE();
led_red_on();
HAL_Delay(1000);
NVIC_SystemReset();
}
and the red led is on after power up.
Only when I connect/disconnect in CubeProgrammer then everything returns to normal operation.