2019-01-09 05:13 AM
Hi.
I want my MCU (STM32F107VCT6) to generate an interrupt when the Vdd is below (e.g.) 2.9V. I have implemented the following init-code:
PWR->CR = PWR_CR_PLS_2V9; // 2.9V
mcu_reg = PWR->CR;
PWR->CR |= PWR_CR_PVDE; // Bit 4 PVDE: Power voltage detector enable.
mcu_reg = PWR->CR;
// For test purposes only ...
// Bit 2 PVDO: PVD output
// This bit is set and cleared by hardware. It is valid only if PVD is enabled by the PVDE bit.
// 0: VDD/VDDA is higher than the PVD threshold selected with the PLS[2:0] bits.
// 1: VDD/VDDA is lower than the PVD threshold selected with the PLS[2:0] bits.
mcu_reg = PWR->CSR;
NVIC_EnableIRQ(PVD_IRQn); // Uses EXTI line 16
Q1: When I run (Keil uV5 and ULINK2) the above init-code, I always read back 0 from both the registers above (as if the contents written is not actually written into the register). Why?
Q2: When I run my application the PVDO-bit is never set, even when the Vdd is below 2.5V. Why?
Q3: It seems like the “PVDO�? bit is not enebled (it is “shaded�? (see below)). Why?
2019-01-09 05:55 AM
Is PWR/BKP enabled and UNLOCKED?
2019-01-11 08:59 AM
Thanks Clive.
Which registers are you referring to?
My "RM0008 Reference manual" is not very specific, and I do not have an example project for this PVD-feature. I would very much appreciate if you could be more specific.
Q1: Is it a RCC->APB1ENR |= RCC_APB1ENR_PWREN you are referring to (that's missing)?
Q2: Which register performs the "UNLOCK"?
Q3: The BKP is "Backup Register"???
I very much appreciate som further clarifications to this matter.
BR Terje