My PVD (Programmable Voltage Detector) don’t work
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 16Q1: 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?