2023-04-14 12:18 AM
I want to use the PVD function of my STM32U5(but I think this applies to nearly all STM32s) to detect when my supply voltage goes over(!) a specific threshold. But it might already be there when I enable PVD. Since this means looking for a zero on PVDO, I need to make sure that I actually have a valid value once I read in PVDO. So how long do I have to wait to make sure that value is valid? The datasheet only mentions a scan rate for ULPMEN = 1. Is the output value really valid one clock after setting PVDE otherwise?
2023-04-19 01:29 AM
By testing I found that some instructions in between are needed, but I am not sure how many and can not find a figure in the datasheet stating anything in that regard. If I block for 1µs its ok. If I exit my busy wait function directly (around 0,2µs) it's also ok, but if I only have 3 instructions (for setting an Exti trigger) between enable and reading the value, the value is not yet set.
2023-04-19 02:03 AM
Hi @Oliver Müller
We do not have a fixed order of magnitude, it will depend on several parameters, but in agreement with the team concerned, what you can do to be sure of the value is valid is to redo a reading of the enable bit after the 'to have activated.that will be enough to ensure that the value is indeed valid.
Regards
Diane
2023-04-19 03:06 AM
Ok, so just poll PVDE after it was written? I'll try that.
EDIT: Tried it, didn't work
This was my test code:
PWR->SVMCR = (PWR->SVMCR & ~PWR_SVMCR_PVDLS) | ( ((uint32_t)Level) << PWR_SVMCR_PVDLS_Pos);
PWR->SVMCR |= PWR_SVMCR_PVDE;
while((PWR->SVMCR & PWR_SVMCR_PVDE) == 0)
{
//wait for data update
}
if( ((PWR->SVMSR & PWR_SVMSR_PVDO) == 0) && (s_VmonCallback != NULL))
{ //directly call callback if level was already there
s_VmonCallback();
}
2023-05-10 10:20 AM
Hi @Oliver Müller
What do you need to say by "it's not working" ?
Regards
Diane
2023-05-10 02:47 PM
> to be sure of the value is valid is to redo a reading of the enable bit
The topic author asked about delay for PVDO bit because of analog circuitry, but "the team" answered about ensuring the state of the PVDE bit, which is not the main issue here.
2023-05-10 11:57 PM
As @Piranha pointed out I do not only need the unit digitally enabled but also the analog part in a steady state. If I only poll for PVDE, the PVDO value still does not reflect the actual state of the external voltage (which in my case leads to forcing my application into brownout because I will start using too much power too soon) .