In the interrupt service function, the printing function must not be used, because the printing function takes too long, which will cause the interrupt service function to not exit for a long time, which will cause some unexpected results.
For example, in the serial port interrupt:
void USART2_IRQHandler(void)
{
unsigned char res;
uint16_t uhdata;
uint16_t uhMask = (&huart2)->Mask;
//if(USART2->ISR&(1<<5))//?????
if(((READ_REG((&huart2)->Instance->ISR) & USART_ISR_RXNE) != RESET) && ((READ_REG((&huart2)->Instance->CR1) & USART_CR1_RXNEIE) != RESET))
{
res = 0;
res = USART2->RDR;
printf("\r\n USART2 IRQ....%x %d \r\n",res,cnt2++);
if('$' == res)
{cnt =0;memset(USART2_RMCtmp_BUF,0,256);}
USART2_RMCtmp_BUF[cnt] = res;
if((cnt>=3) && (USART2_RMCtmp_BUF[3] == 'R'))
{
USART2_RMC_BUF[cnt] = res;
}
cnt++;
}
}
result:
You can see that the received result is 0d 0a, and then nothing. Because the printing function takes too long, the value in the RDR register is not read immediately, which will cause an overflow error, and thus the receiving interrupt cannot be entered to process data. When the printing function is removed, everything is normal.
Therefore, do not perform time-consuming operations in the interrupt service function, especially in the receiving interrupt service function.
Previous article:About SysTick interrupt in interrupt nesting
Next article:stm32 interrupt service function name table quick check
- 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
- CGD and Qorvo to jointly revolutionize motor control solutions
- CGD and Qorvo to jointly revolutionize motor control solutions
- Keysight Technologies FieldFox handheld analyzer with VDI spread spectrum module to achieve millimeter wave analysis function
- Infineon's PASCO2V15 XENSIV PAS CO2 5V Sensor Now Available at Mouser for Accurate CO2 Level Measurement
- Advanced gameplay, Harting takes your PCB board connection to a new level!
- Advanced gameplay, Harting takes your PCB board connection to a new level!
- A new chapter in Great Wall Motors R&D: solid-state battery technology leads the future
- Naxin Micro provides full-scenario GaN driver IC solutions
- Interpreting Huawei’s new solid-state battery patent, will it challenge CATL in 2030?
- Are pure electric/plug-in hybrid vehicles going crazy? A Chinese company has launched the world's first -40℃ dischargeable hybrid battery that is not afraid of cold
- What is the concept of nano power supply?
- loto instrument_How to simulate the output of camshaft and crankshaft waveforms_using arbitrary waveform signal source SIG852?
- About CAN communication rate setting
- ADC and DAC special study
- MicroPython drives Weixue 2.13-inch ink screen (electronic paper)
- IC1B logic probe circuit diagram
- ESP32-S2-Saola-1 running circuitpython(1)
- "Recommended Chinese chips" + domestic high-precision ADC and ultrasonic measurement circuit
- [Hua Diao Experience] 18-line empty board lights up WS2812B's 256-bit LED hard screen
- JTAG does not recognize FPGA