微波EDA网,见证研发工程师的成长!
首页 > 硬件设计 > 嵌入式设计 > STM32 定时器2+串口

STM32 定时器2+串口

时间:11-09 来源:互联网 点击:

/*******************************************************************************
* Function Name : TIM4_IRQHandler
* Description : This function handles TIM4 global interrupt request.
* Input : None
* Output : None
* Return : None
*******************************************************************************/
void TIM4_IRQHandler(void)
{
}

/*******************************************************************************
* Function Name : I2C1_EV_IRQHandler
* Description : This function handles I2C1 Event interrupt request.
* Input : None
* Output : None
* Return : None
*******************************************************************************/
void I2C1_EV_IRQHandler(void)
{
}

/*******************************************************************************
* Function Name : I2C1_ER_IRQHandler
* Description : This function handles I2C1 Error interrupt request.
* Input : None
* Output : None
* Return : None
*******************************************************************************/
void I2C1_ER_IRQHandler(void)
{
}

/*******************************************************************************
* Function Name : I2C2_EV_IRQHandler
* Description : This function handles I2C2 Event interrupt request.
* Input : None
* Output : None
* Return : None
*******************************************************************************/
void I2C2_EV_IRQHandler(void)
{
}

/*******************************************************************************
* Function Name : I2C2_ER_IRQHandler
* Description : This function handles I2C2 Error interrupt request.
* Input : None
* Output : None
* Return : None
*******************************************************************************/
void I2C2_ER_IRQHandler(void)
{
}

/*******************************************************************************
* Function Name : SPI1_IRQHandler
* Description : This function handles SPI1 global interrupt request.
* Input : None
* Output : None
* Return : None
*******************************************************************************/
void SPI1_IRQHandler(void)
{
}

/*******************************************************************************
* Function Name : SPI2_IRQHandler
* Description : This function handles SPI2 global interrupt request.
* Input : None
* Output : None
* Return : None
*******************************************************************************/
void SPI2_IRQHandler(void)
{
}

/*******************************************************************************
* Function Name : USART1_IRQHandler
* Description : This function handles USART1 global interrupt request.
* Input : None
* Output : None
* Return : None
*******************************************************************************/
extern u8 Uart1_Get_Flag;
extern u8 Uart1_Get_Data;

void USART1_IRQHandler(void)
{
//接收中断
if(USART_GetITStatus(USART1,USART_IT_RXNE)==SET)
{
USART_ClearITPendingBit(USART1,USART_IT_RXNE);
Uart1_Get_Data=USART_ReceiveData(USART1);
Uart1_Get_Flag=1;
}

//溢出-如果发生溢出需要先读SR,再读DR寄存器 则可清除不断入中断的问题
if(USART_GetFlagStatus(USART1,USART_FLAG_ORE)==SET)
{
USART_ClearFlag(USART1,USART_FLAG_ORE); //读SR
USART_ReceiveData(USART1); //读DR
}
}

main.c

/************************************************************
**实验名称:Timer
**功能:实现Timer2的4组比较中断,此为STM32定时器的其中一个功能.4段捕获比较分别驱动四个LED点亮,
溢出中断则负责熄灭LED.
对于其它的定时器,基本用法均一样(除T1,T8高级定时器)
**注意事项:注意要开放stm32f10x_conf.h中的 #include "stm32f10x_tim.h" ,#include "misc.h"
**作者:电子白菜
*************************************************************/

#include "STM32Lib\\stm32f10x.h"
#include "hal.h"
#define SIZE 0
u8 table[11]={"0123456789 "};
char buffer[10]={"0000000000"};
void Delay(u16 n);

Copyright © 2017-2020 微波EDA网 版权所有

网站地图

Top