关于STM32的可编程电压检测器的使用方法
关于STM32的可编程电压检测器的使用方法
思维导图总览:
代码:
1 #include "sys.h"
2 #include "delay.h"
3 #include "usart.h"
4 #include "led.h"
5 #include "oled.h"
6 #include "24cxx.h"
7 #include "w25qxx.h"
8
9 #include "key.h"
10 #include "adc.h"
11 #include "npa.h"
12 #include "bluetooth.h"
13 #include "rtc.h"
14
15 const u8 TEXT_Buffer[]={"SPI3 TEST"};
16
17 const u8 AT_Buffer[]={"AT\n\r"};
18 #define SIZE sizeof(TEXT_Buffer)
19 #define At_SIZE sizeof(AT_Buffer)
20
21 void PVD_Config(void);
22 int main(void)
23 {
24 PVD_Config();
25
26 NVIC_PriorityGroupConfig(NVIC_PriorityGroup_2);//设置系统中断优先级分组2
27 delay_init(168); //初始化延时函数
28 //uart_init(115200); //初始化串口波特率为115200
29 //AT24CXX_Init();
30 LED_Init(); //初始化LED
31 oled_init();
32 //W25QXX_Init();
33 KEY_Init();
34 //Adc_Init();
35 // NPAsensor_Bar_Init();
36 LED_Init();
37 LED0=1;
38 //My_RTC_Init(); //初始化RTC
39 //RTC_Set_WakeUp(RTC_WakeUpClock_CK_SPRE_16bits,0); //配置WAKE UP中断,1秒钟中断一次
40
41 //BLUT_Init();
42 //BLUT_SW=0;
43
44
45 //oled_memery_clear(0x00);
46 oled_display_chs((unsigned char *)"ok:",0,0,16,0);
47 oled_display_refresh();
48
49
50
51
52
53 while(1)
54 {
55
56 if(PWR_GetFlagStatus(PWR_FLAG_PVDO)==RESET)
57 {
58 oled_display_chs((unsigned char *)"reset:",0,32,16,0);
59 oled_display_refresh();
60 }
61 else
62 {
63 oled_display_chs((unsigned char *)"set:",0,46,16,0);
64 oled_display_refresh();
65 }
66 }
67 }
68 /**
69 00083 * @brief Configures the PVD resources.
70 00084 * @param None
71 00085 * @retval None
72 00086 */
73 void PVD_Config(void)
74 {
75 NVIC_InitTypeDef NVIC_InitStructure;
76 EXTI_InitTypeDef EXTI_InitStructure;
77
78 /* Enable PWR clock */
79 RCC_APB1PeriphClockCmd(RCC_APB1Periph_PWR, ENABLE);
80
81 /* Configure one bit for preemption priority */
82 NVIC_PriorityGroupConfig(NVIC_PriorityGroup_1);
83
84 /* Enable the PVD Interrupt */
85 NVIC_InitStructure.NVIC_IRQChannel = PVD_IRQn;
86 NVIC_InitStructure.NVIC_IRQChannelPreemptionPriority = 0;
87 NVIC_InitStructure.NVIC_IRQChannelSubPriority = 0;
88 NVIC_InitStructure.NVIC_IRQChannelCmd = ENABLE;
89 NVIC_Init(&NVIC_InitStructure);
90 /* Configure EXTI Line16(PVD Output) to generate an interrupt on rising and
91 falling edges */
92 EXTI_ClearITPendingBit(EXTI_Line16);
93 EXTI_InitStructure.EXTI_Line = EXTI_Line16;
94 EXTI_InitStructure.EXTI_Mode = EXTI_Mode_Interrupt;
95 EXTI_InitStructure.EXTI_Trigger = EXTI_Trigger_Rising_Falling;//change EXTI_Trigger_Rising_Falling
96 EXTI_InitStructure.EXTI_LineCmd = ENABLE;
97 EXTI_Init(&EXTI_InitStructure);
98
99 /* Configure the PVD Level to 3 (PVD detection level set to 2.5V, refer to the
100 electrical characteristics of you device datasheet for more details) */
101 PWR_PVDLevelConfig(PWR_PVDLevel_5);
102
103 /* Enable the PVD Output */
104 PWR_PVDCmd(ENABLE);
105 }
106
107 /******************************************************************************/
108 /* STM32F4xx Peripherals Interrupt Handlers */
109 /* Add here the Interrupt Handler for the used peripheral(s) (PPP), for the */
110 /* available peripheral interrupt handler's name please refer to the startup */
111 /* file (startup_stm32f40xx.s.startup_stm32f427x.s). */
112 /******************************************************************************/
113
114 /**
115 * @brief This function handles the PVD Output interrupt request.
116 * @param None
117 * @retval None
118 */
119 void PVD_IRQHandler(void)
120 {
121 if(EXTI_GetITStatus(EXTI_Line16) != RESET)
122 {
123 /* Toggle LED1 */
124 // STM_EVAL_LEDToggle(LED1);
125 LED0=0;
126 oled_display_chs((unsigned char *)"low",0,16,16,0);
127 oled_display_refresh();
128
129
130
131 /* Clear the Key Button EXTI line pending bit */
132 EXTI_ClearITPendingBit(EXTI_Line16);
133 }
134 }
来源自 STM32官方的帮助文档,这部分资料在帮助文档中都有,而且有代码
关于STM32的可编程电压检测器的使用方法的更多相关文章
- Stm32外围模块编程初始化步骤
Stm32外围模块编程初始化步骤: 一.外部中断 1)初始化 IO 口为输入. 这一步设置你要作为外部中断输入的 IO 口的状态,可以设置为上拉/下拉输入,也可以设置为浮空输入,但浮空的时候外部一定要 ...
- [转载]Javascript异步编程的4种方法
NodeJs的最大特性就是"异步" 目前在NodeJs里实现异步的方法中,使用“回调”是最常见的. 其实还有其他4种实现异步的方法: 在此以做记录 --- http://www.r ...
- (转)javascript异步编程的四种方法
本文转自:http://www.ruanyifeng.com/blog/2012/12/asynchronous%EF%BC%BFjavascript.html 作者:阮一峰 本文仅仅作为个人mark ...
- Javascript异步编程的4种方法
你可能知道,Javascript语言的执行环境是"单线程"(single thread). 所谓"单线程",就是指一次只能完成一件任务.如果有多个任务,就必 ...
- Javascript 异步编程的4种方法
你可能知道,Javascript语言的执行环境是"单线程"(single thread). 所谓"单线程",就是指一次只能完成一件任务.如果有多个任务,就必须排 ...
- C#脱离Halcon编程开发环境使用方法
在没有安装Halcon开发程序(HDevelop (SSE2))的电脑上面编程,使C#脱离Halcon编程开发环境使用方法,除了按照Halcon与编程环境必须要做的设置步骤外,还需要做如下两个工作: ...
- Javascript 异步编程的4种方法详解
你可能知道,Javascript语言的执行环境是"单线程"(single thread). 所谓"单线程",就是指一次只能完成一件任务.如果有多个任务,就必须排 ...
- iOS开发之动画编程的几种方法
iOS开发之动画编程的几种方法 IOS中的动画总结来说有五种:UIView<block>,CAAnimation<CABasicAnimation,CATransition,CAKe ...
- 转:Javascript异步编程的4种方法
你可能知道,Javascript语言的执行环境是"单线程"(single thread). 所谓"单线程",就是指一次只能完成一件任务.如果有多个任务,就必须排 ...
随机推荐
- (Set, Map, Collections工具类)JAVA集合框架二
Java集合框架部分细节总结二 Set 实现类:HashSet,TreeSet HashSet 基于HashCode计算元素存放位置,当计算得出哈希码相同时,会调用equals判断是否相同,相同则拒绝 ...
- Spring (三)SpringAoP
1.Spring 的 AOP 简介 1.1 什么是 AOP AOP 为 Aspect Oriented Programming 的缩写,意思为面向切面编程,是通过预编译方式和运行期动态代理实现程序功能 ...
- linux系统调用号查询(pwn)
做pwn题时遇到程序使用了64位系统调用号:59和15,这里做一下记录 在线查询链接:https://syscalls.w3challs.com/ 分为32位和64位,链接中还有arm.mips等架构 ...
- Hadoop完整搭建过程(四):完全分布模式(服务器)
1 概述 上一篇文章介绍了如何使用虚拟机搭建集群,到了这篇文章就是实战了,使用真实的三台不同服务器进行Hadoop集群的搭建.具体步骤其实与虚拟机的差不多,但是由于安全组以及端口等等一些列的问题,会与 ...
- Digit Counting UVA - 1225
Trung is bored with his mathematics homeworks. He takes a piece of chalk and starts writing a sequ ...
- Day16_98_IO_一边读一边写
一边读一边写 import java.io.FileInputStream; import java.io.FileNotFoundException; import java.io.FileOutp ...
- ServletConfig和ServletContext接口
ServletConfig 在web.xml文件中使用一个或多个init-param元素进行配置后,Tomcat初始化Servlet时,都会将该Servlet的配置信息封装到一个ServletConf ...
- 所谓 ICMP,不过将军与士卒而已
什么是 ICMP 协议 关于这点我们在 IP 协议那篇文章中提过一嘴,IP 协议作为一种提供不可靠数据交付的网络层协议,在传输的过程中,其 IP 数据报可能会发生丢失.重复.延迟和乱序等各种情况, 但 ...
- 1027 Colors in Mars
People in Mars represent the colors in their computers in a similar way as the Earth people. That is ...
- 5403. Find the Kth Smallest Sum of a Matrix With Sorted Rows
You are given an m * n matrix, mat, and an integer k, which has its rows sorted in non-decreasing or ...