如果VDD或者VDDA电压高于或低于PVD设定阈值都产生中断,表现为每中断一次,LED1就亮变灭或者灭变亮。
/********************************************************************************
* @file PWR/PVD/main.c
* @author MCD Application Team
* @version V3.4.0
* @date 10/15/2010
* @brief Main program body.
******************************************************************************/
/* Includes ------------------------------------------------------------------*/
#include 'stm32f10x.h'
#include 'stm32_eval.h'
void EXTI_Configuration(void);
void NVIC_Configuration(void);
/**
* @brief Main program.
* @param None
* @retval None
*/
int main(void)
{
/*!< At this stage the microcontroller clock setting is already configured,
this is done through SystemInit() function which is called from startup
file (startup_stm32f10x_xx.s) before to branch to application main.
To reconfigure the default setting of SystemInit() function, refer to
system_stm32f10x.c file
*/
/* Initialize LEDs and Key Button mounted on STM3210X-EVAL board */
STM_EVAL_LEDInit(LED1);
GPIO_SetBits(GPIOC, GPIO_Pin_7);
/* Enable PWR and BKP clock */
RCC_APB1PeriphClockCmd(RCC_APB1Periph_PWR | RCC_APB1Periph_BKP, ENABLE);//电源管理部分时钟开启
/* Configure EXTI Line to generate an interrupt on falling edge */
EXTI_Configuration();
/* NVIC configuration */
NVIC_Configuration();
/* Configure the PVD Level to 2.9V */
PWR_PVDLevelConfig(PWR_PVDLevel_2V9);// 设定监控阀值
/* Enable the PVD Output */
PWR_PVDCmd(ENABLE);// 使能PVD
while (1)
{
}
}
/**
* @brief Configures EXTI Lines.
* @param None
* @retval None
*/
void EXTI_Configuration(void)
{
EXTI_InitTypeDef EXTI_InitStructure;
/* Configure EXTI Line16(PVD Output) to generate an interrupt on rising and
falling edges */
EXTI_ClearITPendingBit(EXTI_Line16);
EXTI_InitStructure.EXTI_Line = EXTI_Line16;// PVD连接到中断线16上
EXTI_InitStructure.EXTI_Mode = EXTI_Mode_Interrupt;//使用中断模式
EXTI_InitStructure.EXTI_Trigger = EXTI_Trigger_Rising_Falling;//电压上升或下降越过设定阀值时都产生中断。
EXTI_InitStructure.EXTI_LineCmd = ENABLE;// 使能中断线
EXTI_Init(&EXTI_InitStructure);// 初始
}
/**
* @brief Configures NVIC and Vector Table base location.
* @param None
* @retval None
*/
void NVIC_Configuration(void)
{
NVIC_InitTypeDef NVIC_InitStructure;
/* Configure one bit for preemption priority */
NVIC_PriorityGroupConfig(NVIC_PriorityGroup_1);//中断优先级配置
/* Enable the PVD Interrupt */ //设置PVD中断
NVIC_InitStructure.NVIC_IRQChannel = PVD_IRQn;
NVIC_InitStructure.NVIC_IRQChannelPreemptionPriority = 0;
NVIC_InitStructure.NVIC_IRQChannelSubPriority = 0;
NVIC_InitStructure.NVIC_IRQChannelCmd = ENABLE;
NVIC_Init(&NVIC_InitStructure);
}
/******************* (C) COPYRIGHT 2010 STMicroelectronics *****END OF FILE****/
注意:GPIO驱动LED模式为GPIO_InitStructure.GPIO_Mode = GPIO_Mode_Out_PP;还是推挽输出。
中断处理函数:
void PVD_IRQHandler(void)
{
if(EXTI_GetITStatus(EXTI_Line16) != RESET)
{
/* LED1翻转 */
STM_EVAL_LEDToggle(LED1);
/* Clear the Key Button EXTI line pending bit */
EXTI_ClearITPendingBit(EXTI_Line16);
}
}
上一篇:STM32硬件电路设计注意事项
下一篇:STM32之Flash
推荐阅读最新更新时间:2026-03-20 11:43
- 使用 ON Semiconductor 的 FAN2518S 的参考设计
- LTC1530S8、3.3V/3A 稳压器
- 使用 ON Semiconductor 的 ADP3167 的参考设计
- 使用 Analog Devices 的 LT3420EDD 的参考设计
- 基于Kinetis® M的低成本单相电表参考设计
- LTC3708、具有上升/下降轨跟踪功能的 2.5V/15A 和 1.2V/15A 稳压器
- NXQ1TXH5插件板
- 应变仪仪表放大器
- WRL-13287,基于 ESP8266 802.11 无线局域网的 SparkFun Wi-Fi Shield
- 4.1W、3-LED 通用 LED 照明驱动器
- 了解一下: 影响AC-DC/DC-DC转换效率的主要因素有哪些?
- 急求CETK 一小部分源码
- 推荐:TI 即将开始的 Corte-M4&安全系列 技术研讨会!(10.25-10.27)
- C2000™ Piccolo™ LaunchPad Evalution Kit
- 手机单向收费历程 破冰之旅艰难前行
- 关于锅仔片PCB设计要求的一些问题
- 【CN0096】高频AD8331 VGA与10位、 65 MSPS/80 MSPS/105 MSPS ADC AD9215的接口
- i2c器件与总线连接的理解
- beaglebone black的LCD cape 效果图展示
- 有谁整过S3C6400板子?大家用S3C6400做开发,用的DDR内存是什么型号?我的DDR内存跑NK跑到一半就挂了,系统都起不来,NBOOT与EBOOT都行!

stm32驱动屏IC rm68042
STM32 PMSM FOC 简介
基于STM32G031的测试测量训练平台完成虚拟仪器实现
现代雷达系统的信号设计
BFR340T






京公网安备 11010802033920号