Skip to main content
OliM
Senior II
April 14, 2023
Question

What is the startup time of PVD?

  • April 14, 2023
  • 4 replies
  • 1391 views

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?

This topic has been closed for replies.

4 replies

OliM
OliMAuthor
Senior II
April 19, 2023

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.

ST Employee
April 19, 2023

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
OliMAuthor
Senior II
April 19, 2023

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

ST Employee
May 10, 2023

Hi @Oliver Müller​ 

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

Regards

Diane

OliM
OliMAuthor
Senior II
May 11, 2023

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

Piranha
Principal III
May 10, 2023

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