void USART2_IRQHandler(void)
{
uchar tmp;
//接收中断
if(USART_GetITStatus(USART2,USART_IT_RXNE)==SET) // 接收 中断
{
USART_ClearITPendingBit(USART2,USART_IT_RXNE); // U1RX_Clear_Intr_Status_Bit;
tmp=USART_ReceiveData(USART2);
}
//USART_IT_TXE // 发送中断
if( USART_GetITStatus(USART2, USART_IT_TXE) == SET ) //一个是TXE=发送数据寄存器空,
{
if(TIndex2 < TCount2)
{
USART_SendData(USART2, TxBuf2[TIndex2++]);
}
else if(TIndex2 == TCount2)
{
USART_SendData(USART2, 0x0D);
TIndex2 ++;
}
else
{ // 因为是 发送寄存器空 的中断,所以发完字符串后必须关掉,
// 否则只要空了,就会进中断 //送數據寄存器空標志位
//fTransmission_Complete=1;
USART_ITConfig(USART2, USART_IT_TXE, DISABLE);
//DIS_485TX(); 为避免提前关闭,导致的发送不全.移至 外部Timer中控制.
}
}
//溢出-如果发生溢出需要先读SR,再读DR寄存器 则可清除不断入中断的问题
if(USART_GetFlagStatus(USART2,USART_FLAG_ORE)==SET)
{
USART_ClearFlag(USART2,USART_FLAG_ORE); // 读SR
USART_ReceiveData(USART2); // 读DR
}
}
Previous article:Use of USART2 in STM32F103
Next article:Differences between LPC17xx Uart0, Uart1, Uart2, and Uart3
- Popular Resources
- Popular amplifiers
- Learn ARM development(16)
- Learn ARM development(17)
- Learn ARM development(18)
- Embedded system debugging simulation tool
- A small question that has been bothering me recently has finally been solved~~
- Learn ARM development (1)
- Learn ARM development (2)
- Learn ARM development (4)
- Learn ARM development (6)
Professor at Beihang University, dedicated to promoting microcontrollers and embedded systems for over 20 years.
- LED chemical incompatibility test to see which chemicals LEDs can be used with
- Application of ARM9 hardware coprocessor on WinCE embedded motherboard
- What are the key points for selecting rotor flowmeter?
- LM317 high power charger circuit
- A brief analysis of Embest's application and development of embedded medical devices
- Single-phase RC protection circuit
- stm32 PVD programmable voltage monitor
- Introduction and measurement of edge trigger and level trigger of 51 single chip microcomputer
- Improved design of Linux system software shell protection technology
- What to do if the ABB robot protection device stops
- From probes to power supplies, Tektronix is leading the way in comprehensive innovation in power electronics testing
- From probes to power supplies, Tektronix is leading the way in comprehensive innovation in power electronics testing
- Sn-doped CuO nanostructure-based ethanol gas sensor for real-time drunk driving detection in vehicles
- Design considerations for automotive battery wiring harness
- Do you know all the various motors commonly used in automotive electronics?
- What are the functions of the Internet of Vehicles? What are the uses and benefits of the Internet of Vehicles?
- Power Inverter - A critical safety system for electric vehicles
- Analysis of the information security mechanism of AUTOSAR, the automotive embedded software framework
- Brief Analysis of Automotive Ethernet Test Content and Test Methods
- How haptic technology can enhance driving safety
- Eat mushrooms and see villains! It's the time of the year again when Yunnan people poison themselves
- Getting Started with Modelsim
- Crosstalk Elimination Technology in Altium Designer
- Evaluation Weekly Report 20220207: How many days are left to apply for Qinheng ch582 and Pingtouge Linux RISC-V kit
- ESD resistance of capacitors
- Date in spring + small flowers blooming in the spring bushes
- [Sipeed LicheeRV 86 Panel Review] Debian Python + Serial Communication
- What is the 5G battle about?
- Zero-based development of WIFI devices
- A detailed description of the development history of Bluetooth technology from 1.0 to 5.0