cancel
Showing results for 
Search instead for 
Did you mean: 

What is the startup time of PVD?

OliM
Senior

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?

6 REPLIES 6
OliM
Senior

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.

Diane POMABIA
ST Employee

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

OliM
Senior

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();
    }

Hi @Oliver Müller​ 

What do you need to say by "it's not working" ?

Regards

Diane

Piranha
Chief II

> 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.

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) .