Problems found when debugging STM8/stm32 serial port

Publisher:sunyouz1Latest update time:2015-09-21 Source: eefocusKeywords:STM8 Reading articles on mobile phones Scan QR code
Read articles on your mobile phone anytime, anywhere
Description: Serial port interrupt 1 is used for received data. I use the serial port assistant to send an 8-byte data, and then I want to check whether the 8 bytes are received by the single chip. For example, the data is 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07, 0x08.
 
  #pragma  vector=ITC_IRQ_UART1_RX + 2    
    __interrupt void Uart1RxdInt(void)
    { // This function has completed clearing the interrupt flag
     u8 right;
     if(UART1_GetFlagStatus(UART1_FLAG_RXNE)!=RESET)
     {
      tmp = UART1_ReceiveData8();
     
   ret=UART_KbdPkgRead(tmp);
if(ret==0)
{
KBD_Flag_COOL=1;
}
     }
    }
 I set a breakpoint at ret, and then every time I send an interrupt, I find that I can stop there, and the received data is indeed 0x01, and then run at full speed, the received data is also 0x02, and when running at full speed, it may be 0x01 again or it may not stop at all.
Only then did I realize that I had made a mistake. When sending a string of data, the breakpoint should not be set within the interrupt, because the CPU will not stop at the breakpoint, which means that the string of data will be missed. If you send a number, it will not be missed.
What to do next?
Enter the interrupt function, for example, mine is UART_KbdPkgRead(). After entering, you can write a small program to determine whether the received data is to be sent, such as if (dat==0x01), if (dat==0x02). In this way, set a breakpoint in front of it to determine whether this string of data is received by the microcontroller.
Keywords:STM8 Reference address:Problems found when debugging STM8/stm32 serial port

Previous article:About the difference between i2c and spi protocols for debugging stm32 and stm8 (51 microcontroller)
Next article:Configuration when using the serial port printf() function

Latest Microcontroller Articles
Change More Related Popular Components

EEWorld
subscription
account

EEWorld
service
account

Automotive
development
circle

About Us Customer Service Contact Information Datasheet Sitemap LatestNews


Room 1530, 15th Floor, Building B, No.18 Zhongguancun Street, Haidian District, Beijing, Postal Code: 100190 China Telephone: 008610 8235 0740

Copyright © 2005-2024 EEWORLD.com.cn, Inc. All rights reserved 京ICP证060456号 京ICP备10001474号-1 电信业务审批[2006]字第258号函 京公网安备 11010802033920号