When calling the following SPI function during debugging, the following two problems were found:
1. If you set a breakpoint at the third line while (SPI_I2S_GetFlagStatus(SPI2, SPI_I2S_FLAG_RXNE) == RESET);, it will get stuck in this while statement and cause the watchdog to reset;
2. Running at full speed will trigger the watchdog reset program. The program only calls spi without interruption. It is determined that it is caused by spi. The SPI rate drops from 16M to 2M, and there is no reset in a short time.
uint8_t SPI2_SendOneByte(uint8_t u8Data) //SPI2 sends one byte
{
/* Wait for the send buffer to be empty, TXE event*/
while (SPI_I2S_GetFlagStatus(SPI2, SPI_I2S_FLAG_TXE) == RESET);
/* Write the data register and write the data to be written into the send buffer*/
SPI_I2S_SendData(SPI2, u8Data);
/* Wait for the receive buffer to be non-empty, RXNE event*/
while (SPI_I2S_GetFlagStatus(SPI2, SPI_I2S_FLAG_RXNE) == RESET);
/* Read the data register and get the receive buffer data*/
return SPI_I2S_ReceiveData(SPI2);
}
After testing and consulting online information, it was found that it was caused by tracking the SPI register during debugging. The solution is to close the corresponding SPI register tracking window during debugging. The specific reason was not found in the official document. I saw such a paragraph on the Internet, which can explain this imagination:
During the debugging process, the status of peripheral registers can be easily viewed using the register or memory display window of the debugging software.
Many friends have encountered this problem: during single-step debugging, they can never see changes in certain flag bits in the display window. When these flag bits should be set, they are displayed as 0 in the window. Many people mistakenly believe that this is a chip problem.
We know that the status register bits of many STM32 peripherals can be cleared by reading certain registers (such as many flag bits in I2C_SR1 of I2C). During the debugging process, whenever the program stops at a set breakpoint or single-step stop, the debugging software will automatically read out the contents of all specified registers and memories and refresh the window display. This read operation of the debugging software happens to clear those flag bits, resulting in the phenomenon described above.
There are several simple ways to solve this problem: 1. Close the register or memory display window. 2. Do not display these sensitive registers in the register or memory display window. 3. Do not place breakpoints before the operation of these sensitive register bits to ensure that these register bits are not accidentally operated by the debugging software.
Previous article:STM32 IIC Detailed Explanation: STM32 IIC Slave Mode (Interrupt Mode to Send and Receive Data)
Next article:STM32F103RC hardware I2C from the pit to the pit
Recommended ReadingLatest update time:2024-11-23 04:47
- Popular Resources
- Popular amplifiers
- Naxin Micro and Xinxian jointly launched the NS800RT series of real-time control MCUs
- How to learn embedded systems based on ARM platform
- Summary of jffs2_scan_eraseblock issues
- Application of SPCOMM Control in Serial Communication of Delphi7.0
- Using TComm component to realize serial communication in Delphi environment
- Bar chart code for embedded development practices
- Embedded Development Learning (10)
- Embedded Development Learning (8)
- Embedded Development Learning (6)
Professor at Beihang University, dedicated to promoting microcontrollers and embedded systems for over 20 years.
- Intel promotes AI with multi-dimensional efforts in technology, application, and ecology
- ChinaJoy Qualcomm Snapdragon Theme Pavilion takes you to experience the new changes in digital entertainment in the 5G era
- Infineon's latest generation IGBT technology platform enables precise control of speed and position
- Two test methods for LED lighting life
- Don't Let Lightning Induced Surges Scare You
- Application of brushless motor controller ML4425/4426
- Easy identification of LED power supply quality
- World's first integrated photovoltaic solar system completed in Israel
- Sliding window mean filter for avr microcontroller AD conversion
- What does call mean in the detailed explanation of ABB robot programming instructions?
- STMicroelectronics discloses its 2027-2028 financial model and path to achieve its 2030 goals
- 2024 China Automotive Charging and Battery Swapping Ecosystem Conference held in Taiyuan
- State-owned enterprises team up to invest in solid-state battery giant
- The evolution of electronic and electrical architecture is accelerating
- The first! National Automotive Chip Quality Inspection Center established
- BYD releases self-developed automotive chip using 4nm process, with a running score of up to 1.15 million
- GEODNET launches GEO-PULSE, a car GPS navigation device
- Should Chinese car companies develop their own high-computing chips?
- Infineon and Siemens combine embedded automotive software platform with microcontrollers to provide the necessary functions for next-generation SDVs
- Continental launches invisible biometric sensor display to monitor passengers' vital signs
- Embedded Expert
- MSP430F5529 ADC sampling example
- [LPC8N04 Review] 3. Brief Analysis of LPC8N04 Chip
- 5 days left to register | Full schedule of the annual AIoT Developer Conference! 19 technical lectures full of practical information!
- RC helicopter battery replacement reminder
- Revealing the secret! How can 100 MHz power decoupling hold Gbps high-speed signals?
- GD32F350 Learning Series 3: TC0 Timing Interrupt Test
- Please tell me how to protect the gas meter using Hall device from strong magnetism, and whether it has one or two Hall devices.
- Identification of Common Components
- ABB continues to lead the new substation automation regulations