STM8 serial port receiving string problem

Publisher:闪耀星空Latest update time:2019-09-16 Source: eefocusKeywords:STM8 Reading articles on mobile phones Scan QR code
Read articles on your mobile phone anytime, anywhere

Attached here is the receive interrupt source code

#ifdef _RAISONANCE_

void USART_RX_IRQHandler(void) interrupt 28

#endif

uint8_t cnt_USART;

#ifdef _IAR_SYSTEMS_

#pragma vector=30

__interrupt void USART_RX_IRQHandler(void)

#endif

{

    /* In order to detect unexpected events during development,

   it is recommended to set a breakpoint on the following instruction.

    */

    USART_ClearITPendingBit (); // Clear interrupt flag

    if(!USART_GetFlagStatus (USART_FLAG_RXNE)) //Wait for reception to complete

    {

    

      p_rxbuf[cnt_USART++] = USART_ReceiveData8(); //Receive data 

      if(cnt_USART == 0x0B)

        cnt_USART = 0xFF;

    }

// USART_RendCmd(p_rxbuf); //Receive 11 bytes serial port command

}

cnt_USART is a global variable. Since only 1 byte is received each time, the main program should perform an appropriate delay to wait for the data in the buffer to be read.

       while(cnt_USART!=0xFF)

       {

        if(mark_1ms >100)

          break;

       }

Perform appropriate delay in the function to wait, mark_1ms here uses TIM2 for delay, and you can also perform empty function delay in the main function.

Keywords:STM8 Reference address:STM8 serial port receiving string problem

Previous article:SPI bus detailed notes
Next article:Solve the problem that stm8 will be stuck in serial port interruption

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号